summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranatoly techtonik <techtonik@gmail.com>2014-12-28 11:27:15 (GMT)
committeranatoly techtonik <techtonik@gmail.com>2014-12-28 11:27:15 (GMT)
commitf4e67e95ae44fbd0734e70c85a29c8b7a603e329 (patch)
tree554b0b3e463108385dd3878d74f9d908babdc4d8
parentfc7798ccedd016225f3e9d4cf9ba4dee40a5b1a4 (diff)
downloadSCons-f4e67e95ae44fbd0734e70c85a29c8b7a603e329.zip
SCons-f4e67e95ae44fbd0734e70c85a29c8b7a603e329.tar.gz
SCons-f4e67e95ae44fbd0734e70c85a29c8b7a603e329.tar.bz2
Improve invalid --config value handling for multiple choices:
Changes output of `scons --config` from: usage: scons [OPTION] [TARGET] ... SCons Error: --config option requires an argument To: usage: scons [OPTION] [TARGET] ... SCons Error: --config option requires an argument (choose from auto, force, cache)
-rw-r--r--src/engine/SCons/Script/SConsOptions.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index d7262a9..8ecc093 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -319,7 +319,13 @@ class SConsOptionParser(optparse.OptionParser):
value = option.const
elif len(rargs) < nargs:
if nargs == 1:
- self.error(_("%s option requires an argument") % opt)
+ if not option.choices:
+ self.error(_("%s option requires an argument") % opt)
+ else:
+ msg = _("%s option requires an argument " % opt)
+ msg += _("(choose from %s)"
+ % ', '.join(option.choices))
+ self.error(msg)
else:
self.error(_("%s option requires %d arguments")
% (opt, nargs))
@@ -645,18 +651,12 @@ def Parser(version):
config_options = ["auto", "force" ,"cache"]
- def opt_config(option, opt, value, parser, c_options=config_options):
- if not value in c_options:
- raise OptionValueError(opt_invalid('config', value, c_options))
- setattr(parser.values, option.dest, value)
-
opt_config_help = "Controls Configure subsystem: %s." \
% ", ".join(config_options)
op.add_option('--config',
- nargs=1, type="string",
+ nargs=1, choices=config_options,
dest="config", default="auto",
- action="callback", callback=opt_config,
help = opt_config_help,
metavar="MODE")