If the help subcommand is given, print the help output.
This isn't a real subcommand like the others. The option processing just intercepts it and prints the output. Given that we're subcommand based, it makes sense to support this in addition to --help. (cherry picked from commit3743d6d208
) (cherry picked from commit3c6478e179
)
This commit is contained in:
parent
d92f2f5b04
commit
18620700fd
@ -47,7 +47,8 @@ def setup_logging(logfile):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse the arguments
|
||||
opts = composer_cli_parser().parse_args()
|
||||
arg_parser = composer_cli_parser()
|
||||
opts = arg_parser.parse_args()
|
||||
|
||||
if opts.showver:
|
||||
print(VERSION)
|
||||
@ -59,6 +60,16 @@ if __name__ == '__main__':
|
||||
setup_logging(opts.logfile)
|
||||
log.debug("opts=%s", opts)
|
||||
|
||||
if len(opts.args) == 0:
|
||||
log.error("Missing command")
|
||||
sys.exit(1)
|
||||
elif opts.args[0] == "help":
|
||||
arg_parser.print_help()
|
||||
sys.exit(0)
|
||||
elif len(opts.args) == 1:
|
||||
log.error("Missing %s sub-command", opts.args[0])
|
||||
sys.exit(1)
|
||||
|
||||
errors = []
|
||||
|
||||
# Check to see if the socket exists and can be accessed
|
||||
|
@ -40,15 +40,12 @@ def main(opts):
|
||||
:param opts: Cmdline arguments
|
||||
:type opts: argparse.Namespace
|
||||
"""
|
||||
if len(opts.args) == 0:
|
||||
log.error("Missing command")
|
||||
return 1
|
||||
elif opts.args[0] not in command_map:
|
||||
|
||||
# Making sure opts.args is not empty (thus, has a command and subcommand)
|
||||
# is already handled in src/bin/composer-cli.
|
||||
if opts.args[0] not in command_map:
|
||||
log.error("Unknown command %s", opts.args[0])
|
||||
return 1
|
||||
if len(opts.args) == 1:
|
||||
log.error("Missing %s sub-command", opts.args[0])
|
||||
return 1
|
||||
else:
|
||||
try:
|
||||
return command_map[opts.args[0]](opts)
|
||||
|
Loading…
Reference in New Issue
Block a user