about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-05-28 21:10:33 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-05-28 21:10:33 +0900
commit53e37aabc2f2f19062a314ce0bf985ae2392d734 (patch)
tree6425f80f47a1b9b1dacf7056085766eb27d183af
parent42b2fb1d329f614822d3c5b080185199e4be98e2 (diff)
downloadscadere-53e37aabc2f2f19062a314ce0bf985ae2392d734.tar.gz
Shorten check's CLI synopsis
-rw-r--r--src/scadere/__init__.py9
1 files changed, 8 insertions, 1 deletions
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 <https://www.gnu.org/licenses/>.
 
-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: