From 53e37aabc2f2f19062a314ce0bf985ae2392d734 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Wed, 28 May 2025 21:10:33 +0900 Subject: Shorten check's CLI synopsis --- src/scadere/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scadere/__init__.py b/src/scadere/__init__.py index 7becab1..ada0f29 100644 --- a/src/scadere/__init__.py +++ b/src/scadere/__init__.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with scadere. If not, see . -from argparse import HelpFormatter +from argparse import HelpFormatter, ONE_OR_MORE __all__ = ['__version__', 'GNUHelpFormatter', 'NetLoc'] __version__ = '0.1.0' @@ -33,6 +33,13 @@ class GNUHelpFormatter(HelpFormatter): """Substitute 'Options:' for 'options:'.""" super().start_section(heading.capitalize()) + def _format_args(self, action, default_metavar): + """Substitute 'METAVAR...' for 'METAVAR [METAVAR ...]'.""" + if action.nargs == ONE_OR_MORE: + get_metavar = self._metavar_formatter(action, default_metavar) + return '{}...'.format(*get_metavar(1)) + return super()._format_args(action, default_metavar) + def _format_action_invocation(self, action): """Format --long-option=argument.""" if not action.option_strings or action.nargs is not None: -- cgit 1.4.1