Fixed command line tool · NetApp/cloudstack@fe2fc63 · GitHub
Skip to content

Commit fe2fc63

Browse files
committed
Fixed command line tool
1 parent ad3c18a commit fe2fc63

6 files changed

Lines changed: 32 additions & 285 deletions

File tree

cloud-cli/cloudapis/amazon.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

cloud-cli/cloudapis/cloud.py

Lines changed: 16 additions & 9 deletions

cloud-cli/cloudtool/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@
1111

1212
def main(argv=None):
1313

14+
#import ipdb; ipdb.set_trace()
1415
if argv == None:
1516
argv = sys.argv
1617

17-
prelim_args = [ x for x in argv[1:] if not x.startswith('-') ]
18+
prelim_args = [ x for x in argv[0:] if not x.startswith('-') ]
1819
parser = utils.get_parser()
19-
20+
2021
api = __import__("cloudapis")
2122
apis = getattr(api, "implementor")
22-
if len(prelim_args) == 0:
23-
parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list(apis)))
24-
elif len(prelim_args) == 1:
23+
if len(prelim_args) == 1:
2524
commandlist = utils.get_command_list(apis)
26-
parser.error("you need to specify a command name as the second argument\n\nCommands supported by the %s API:\n"%prelim_args[0] + "\n".join(commandlist))
25+
parser.error("you need to specify a command name as the first argument\n\nCommands supported by the %s API:\n"%prelim_args[0] + "\n".join(commandlist))
2726

2827
command = utils.lookup_command_in_api(apis,prelim_args[1])
2928
if not command: parser.error("command %r not supported by the %s API"%(prelim_args[1],prelim_args[0]))
29+
30+
argv = argv[1:]
31+
if len(argv) == 1:
32+
argv.append("--help")
3033

3134
parser = utils.get_parser(apis.__init__,command)
32-
argv = argv[1:]
3335
opts,args,api_optionsdict,cmd_optionsdict = parser.parse_args(argv)
3436

3537

@@ -38,7 +40,7 @@ def main(argv=None):
3840
except utils.OptParseError,e:
3941
parser.error(str(e))
4042

41-
command = utils.lookup_command_in_api(api,args[1])
43+
command = utils.lookup_command_in_api(api,args[0])
4244

4345
# we now discard the first two arguments as those necessarily are the api and command names
4446
args = args[2:]

cloud-cli/cloudtool/utils.py

Lines changed: 5 additions & 38 deletions

0 commit comments

Comments
 (0)