Skip to content

Commit

Permalink
Improve help output
Browse files Browse the repository at this point in the history
Don't use type for positional names
  • Loading branch information
mayfield committed Feb 18, 2023
1 parent df0f0e4 commit 880c209
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def long_desc():

setup(
name='shellish',
version='5',
version='5.1',
description='A framework for CLI/shell programs.',
author='Justin Mayfield',
author_email='[email protected]',
Expand All @@ -33,15 +33,14 @@ def long_desc():
]
},
classifiers=[
'Development Status :: 4 - Beta',
# 'Development Status :: 5 - Production/Stable',
# 'Development Status :: 6 - Mature',
'Development Status :: 6 - Mature',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Shells',
]
Expand Down
11 changes: 3 additions & 8 deletions shellish/command/autocommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def setup_args(self, default_parser):
param.KEYWORD_ONLY):
if param.kind == param.KEYWORD_ONLY or \
param.default is not sig.empty:
name = '--%s' % name
name = '--%s' % name.replace('_', '-')
label = 'keyword'
got_keywords = True
else:
Expand All @@ -86,7 +86,7 @@ def setup_args(self, default_parser):
label = 'varargs'
elif param.kind == param.VAR_KEYWORD:
options['nargs'] = argparse.REMAINDER
name = '--%s' % name
name = '--%s' % name.replace('_', '-')
label = 'varkwargs'
help = 'variable key/value args [[--key value] || ' \
'[key=value] ...]'
Expand All @@ -102,12 +102,7 @@ def setup_args(self, default_parser):
del options['type']
else:
options['type'] = lambda x: x.lower() not in self.falsy
else:
try:
options['metavar'] = options['type'].__name__.upper()
except:
pass
action = parser.add_argument(name.replace('_', '-'), **options)
action = parser.add_argument(name, **options)
action.label = label


Expand Down
4 changes: 2 additions & 2 deletions shellish/command/supplement.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ def format_help(self):
title, about = '', desc
else:
title, about = self.description, ''
if title:
if title and title.strip():
formatter.add_text('<b><u>%s</u></b>\n' % title.strip())
if about:
if about and about.rstrip():
formatter.add_text(about.rstrip())
for group in self._action_groups:
formatter.start_section(group.title)
Expand Down

0 comments on commit 880c209

Please sign in to comment.