From fb9a3a9b2daa21317d0adceca86215c393e975e6 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 12 Dec 2022 18:08:07 +0000 Subject: [PATCH] Strip trailing periods when getting description This yields slightly prettier output. Change-Id: Ibec7cd861eacc3630182d6a782ffaf361f449aa6 Signed-off-by: Stephen Finucane --- cliff/help.py | 2 +- cliff/tests/test_help.py | 4 ++-- .../strip-period-from-help-strings-be368e5cf5bd5269.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/strip-period-from-help-strings-be368e5cf5bd5269.yaml diff --git a/cliff/help.py b/cliff/help.py index 2a235def..af30504d 100644 --- a/cliff/help.py +++ b/cliff/help.py @@ -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 + ')' diff --git a/cliff/tests/test_help.py b/cliff/tests/test_help.py index 4862f259..c9b0c8b0 100644 --- a/cliff/tests/test_help.py +++ b/cliff/tests/test_help.py @@ -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) diff --git a/releasenotes/notes/strip-period-from-help-strings-be368e5cf5bd5269.yaml b/releasenotes/notes/strip-period-from-help-strings-be368e5cf5bd5269.yaml new file mode 100644 index 00000000..9577e910 --- /dev/null +++ b/releasenotes/notes/strip-period-from-help-strings-be368e5cf5bd5269.yaml @@ -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.