aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-05-28 19:17:57 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-20 18:01:21 +0100
commit833342e766888dbe11f4dc568f9d50192179df5f (patch)
tree1016d81f4d08a2074a0b3d571fc21ad9e3265bde
parentc65e99f2d456caaf9123be6c40e44c7ab9432b50 (diff)
downloadsos-833342e766888dbe11f4dc568f9d50192179df5f.tar.gz
[sosreport] use short option -v for verbosity in --list-presets
The --verbosity arg is a bit awkward in preset listings as it is a count type. The literal value is 1, 2, or 3, but the user enters it by repeating either the short or long option. Ideally, a user should be able to paste the arguments from the --list-presets output into the terminal and use them as arguments to sosreport: using the long option for this is... verbose: "--verbosity --verbosity --verbosity". Special case this option and use the short version instead: "-vvv". name: vvverbose-debug description: options: --debug -vvv Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 16f0dc82..90231fab 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -882,9 +882,17 @@ class SoSReport(object):
def argify(opt):
""" Convert sos option notation to command line arguments.
"""
- arg = "--" + opt
+ # Handle --verbosity specially
+ if opt.startswith("verbosity"):
+ (arg, value) = opt.split("=")
+ arg = "-" + int(value) * "v"
+ return arg
+
+ # Convert "a_name=value" to "--a-name=value" and
+ # "name=True" to "--name"
+ arg = "--" + opt if len(opt) > 1 else "-" + opt
arg = arg.replace("_", "-")
- arg = arg.strip("=True")
+ arg = arg[:-len("=True")] if arg.endswith("=True") else arg
return arg
def has_value(opt):