From 833342e766888dbe11f4dc568f9d50192179df5f Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 28 May 2018 19:17:57 +0100 Subject: [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 --- sos/sosreport.py | 12 ++++++++++-- 1 file 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): -- cgit