aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-11-09 18:13:31 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-11-10 12:17:50 -0500
commit4eef30fa8e5cfbc1a154a669396c0635fb36a5ad (patch)
treedb65b1f499cac61353ad6c4e2fe67b4dfeea2ff1
parentdfd6fe7acdac5d7e96c0aa06c287d164241bba4c (diff)
downloadsos-4eef30fa8e5cfbc1a154a669396c0635fb36a5ad.tar.gz
[sos] Fix argparse error output formatting
Error message propagation from the subparsers was causing the error message to be mangled with the usage string from the "main" parser when an invalid argument value was passed. After discussion with python upstream, while this is an issue with the subparser formatting (as %(prog) is being set to the main parser's usage), there are simple paths around this behavior so a code change there will not be forthcoming. Instead, override the subparser's prog to be a single line string instead of the main parser's usage string. Closes: #2285 Resolves: #2301 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/__init__.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sos/__init__.py b/sos/__init__.py
index cc8ce86f..628d8fbd 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py
@@ -110,7 +110,8 @@ class SoS():
for comp in self._components:
_com_subparser = self.subparsers.add_parser(
comp,
- aliases=self._components[comp][1]
+ aliases=self._components[comp][1],
+ prog="sos %s" % comp
)
_com_subparser.usage = "sos %s [options]" % comp
_com_subparser.register('action', 'extend', SosListOption)