Commit 5786c087 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cli: Use list of options shared between commands

The completion script for bash has to know about these options. Until now
the list was in two places--once in and once in
autotools/build-bash-completion. A shared list is used with this patch.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 6760e4ed
......@@ -575,11 +575,14 @@ def GetCommands(filename, module):
help_option = cli.cli_option("-h", "--help", default=False,
for (_, _, optdef, _, _) in commands.itervalues():
for name, (_, _, optdef, _, _) in commands.items():
if help_option not in optdef:
if cli.DEBUG_OPT not in optdef:
for opt in cli.COMMON_OPTS:
if opt in optdef:
raise Exception("Common option '%s' listed for command '%s' in %s" %
(opt, name, filename))
# Use aliases
aliases = getattr(module, "aliases", {})
......@@ -1029,6 +1029,9 @@ NODRBD_STORAGE_OPT = cli_option("--no-drbd-storage", dest="drbd_storage",
action="store_false", default=True,
help="Disable support for DRBD")
#: Options provided by all commands
def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments.
......@@ -1096,7 +1099,7 @@ def _ParseArgs(argv, commands, aliases):
cmd = aliases[cmd]
func, args_def, parser_opts, usage, description = commands[cmd]
parser = OptionParser(option_list=parser_opts + [DEBUG_OPT],
parser = OptionParser(option_list=parser_opts + COMMON_OPTS,
usage="%%prog %s %s" % (cmd, usage))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment