aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-05-25 21:45:57 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-20 18:01:21 +0100
commit376e59b98dd192f481ab57429d5fa3c3c0c7d092 (patch)
tree40ffd8d6fb21a5394c5b92cbade97fd4f1e03c04
parent21da9daf5a0c584a7406474f6f8cb763bd4c2c86 (diff)
downloadsos-376e59b98dd192f481ab57429d5fa3c3c0c7d092.tar.gz
[sosreport] add command line defaults dictionary
Add a dictionary mapping all argument names with a non-zero default value to the appropriate default. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 672030aa..0b8b0cd1 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -199,6 +199,22 @@ class XmlReport(object):
# valid modes for --chroot
chroot_modes = ["auto", "always", "never"]
+#: Names of all arguments
+_arg_names = [
+ 'all_logs', 'batch', 'build', 'case_id', 'chroot', 'compression_type',
+ 'config_file', 'debug', 'enableplugins', 'experimental', 'label',
+ 'list_plugins', 'list_profiles', 'log_size', 'noplugins', 'noreport',
+ 'onlyplugins', 'plugopts', 'profiles', 'quiet', 'sysroot', 'tmp_dir',
+ 'usealloptions', 'verbosity', 'verify'
+]
+
+#: Arguments with non-zero default values
+_arg_defaults = {
+ "log_size": 10,
+ "chroot": "auto",
+ "compression_type": "auto",
+}
+
def _parse_args(args):
""" Parse command line options and arguments"""
@@ -233,7 +249,7 @@ def _parse_args(args):
parser.add_argument("-c", "--chroot", action="store", dest="chroot",
help="chroot executed commands to SYSROOT "
"[auto, always, never] (default=auto)",
- default="auto")
+ default=_arg_defaults["chroot"])
parser.add_argument("--config-file", action="store",
dest="config_file",
help="specify alternate configuration file")
@@ -260,10 +276,9 @@ def _parse_args(args):
dest="list_profiles", default=False,
help="display a list of available profiles and "
"plugins that they include")
- parser.add_argument("--log-size", action="store",
- dest="log_size", default=25, type=int,
- help="set a limit on the size of collected logs "
- "(in MiB)")
+ parser.add_argument("--log-size", action="store", dest="log_size",
+ type=int, default=_arg_defaults["log_size"],
+ help="limit the size of collected logs (in MiB)")
parser.add_argument("-n", "--skip-plugins", action="extend",
dest="noplugins", type=str,
help="disable these plugins", default=deque())
@@ -294,8 +309,8 @@ def _parse_args(args):
parser.add_argument("--verify", action="store_true",
dest="verify", default=False,
help="perform data verification during collection")
- parser.add_argument("-z", "--compression-type",
- dest="compression_type", default="auto",
+ parser.add_argument("-z", "--compression-type", dest="compression_type",
+ default=_arg_defaults["compression_type"],
help="compression technology to use [auto, "
"gzip, bzip2, xz] (default=auto)")
parser.add_argument("-t", "--threads", action="store", dest="threads",
@@ -305,15 +320,6 @@ def _parse_args(args):
return parser.parse_args(args)
-_arg_names = [
- 'all_logs', 'batch', 'build', 'case_id', 'chroot', 'compression_type',
- 'config_file', 'debug', 'enableplugins', 'experimental', 'label',
- 'list_plugins', 'list_profiles', 'log_size', 'noplugins', 'noreport',
- 'onlyplugins', 'plugopts', 'profiles', 'quiet', 'sysroot', 'tmp_dir',
- 'usealloptions', 'verbosity', 'verify'
-]
-
-
class SoSOptions(object):
list_plugins = False
noplugins = []