Strip trailing periods when getting description

This yields slightly prettier output.

Change-Id: Ibec7cd861eacc3630182d6a782ffaf361f449aa6
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2022-12-12 18:08:07 +00:00
parent 91c62985fb
commit fb9a3a9b2d
3 changed files with 9 additions and 3 deletions

View File

@ -75,7 +75,7 @@ class HelpAction(argparse.Action):
if namespace.debug:
traceback.print_exc(file=out)
continue
one_liner = cmd.get_description().split('\n')[0]
one_liner = cmd.get_description().split('\n')[0].rstrip('.')
dist_name = dist_for_obj(factory)
if dist_name and dist_name != app_dist:
dist_info = ' (' + dist_name + ')'

View File

@ -103,8 +103,8 @@ class TestHelp(base.TestBase):
self.assertIn('usage: %s [--version]' % basecommand, help_text)
self.assertRegex(help_text, 'option(s|al arguments):\n --version')
expected = (
' one Test command.\n'
' three word command Test command.\n'
' one Test command\n'
' three word command Test command\n'
)
self.assertIn(expected, help_text)

View File

@ -0,0 +1,6 @@
---
features:
- |
Trailing periods will now be stripped from the oneline summary shown
for the help command. This better aligns with the format used by
argparse itself.