summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-12-12 18:08:07 +0000
committerStephen Finucane <sfinucan@redhat.com>2022-12-12 18:14:52 +0000
commitfb9a3a9b2daa21317d0adceca86215c393e975e6 (patch)
treecc4440429669512608cba13479af2044f2f4d985
parent91c62985fb6c529cecfed5354ae687d62c25a821 (diff)
downloadcliff-fb9a3a9b2daa21317d0adceca86215c393e975e6.tar.gz
Strip trailing periods when getting description4.2.0
This yields slightly prettier output. Change-Id: Ibec7cd861eacc3630182d6a782ffaf361f449aa6 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--cliff/help.py2
-rw-r--r--cliff/tests/test_help.py4
-rw-r--r--releasenotes/notes/strip-period-from-help-strings-be368e5cf5bd5269.yaml6
3 files changed, 9 insertions, 3 deletions
diff --git a/cliff/help.py b/cliff/help.py
index 2a235de..af30504 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 4862f25..c9b0c8b 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 0000000..9577e91
--- /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.