From 89579a68d9f51e51b24f96b933da656afd83edfb Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 23 Aug 2017 18:54:01 -0600 Subject: cli: Fix command line parsing of coniditionally loaded subcommands. In an effort to save file load cost during system boot, certain subcommands, analyze and devel, do not get loaded unless the subcommand is specified on the commandline. Because setup.py entrypoint for cloud-init script doesn't specify sysv_args parameter when calling the CLI's main() we need main to read sys.argv into sysv_args so our subparser loading continues to work. LP: #1712676 --- cloudinit/cmd/main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py index 5b467979..68563e0c 100644 --- a/cloudinit/cmd/main.py +++ b/cloudinit/cmd/main.py @@ -676,11 +676,10 @@ def main_features(name, args): def main(sysv_args=None): - if sysv_args is not None: - parser = argparse.ArgumentParser(prog=sysv_args[0]) - sysv_args = sysv_args[1:] - else: - parser = argparse.ArgumentParser() + if not sysv_args: + sysv_args = sys.argv + parser = argparse.ArgumentParser(prog=sysv_args[0]) + sysv_args = sysv_args[1:] # Top level args parser.add_argument('--version', '-v', action='version', -- cgit v1.2.3