Skip to content

Commit b9a2423

Browse files
committed
fix cloud-tool to list all the available apis
1 parent 3f4feaa commit b9a2423

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

cloud-cli/cloudapis/cloud.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,5 @@ def %s(%s):
111111
implementor = CloudAPI
112112

113113
del name,meth,describe,load_dynamic_methods
114+
115+

cloud-cli/cloudtool/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main(argv=None):
2020
api = __import__("cloudapis")
2121
apis = getattr(api, "implementor")
2222
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()))
23+
parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list(apis)))
2424
elif len(prelim_args) == 1:
2525
commandlist = utils.get_command_list(apis)
2626
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))

cloud-cli/cloudtool/utils.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ def lookup_command_in_api(api,command_name):
165165
command = getattr(api,command_name.replace("-","_"),None)
166166
return command
167167

168-
def get_api_list():
169-
apilist = []
170-
for api in apis.get_all_apis():
171-
api_module = api
172-
api_name = api.__name__.split(".")[-1]
173-
if not api_name.startswith("_") and hasattr(api_module,'__doc__'):
174-
apilist.append( " %20s %s"%(api_name.replace("_",'-'),api_module.__doc__) )
175-
return apilist
168+
def get_api_list(api):
169+
apilist = []
170+
for cmd_name in dir(api):
171+
cmd = getattr(api,cmd_name)
172+
if callable(cmd) and not cmd_name.startswith("_"):
173+
apilist.append(cmd_name)
174+
return apilist
176175

177176
def get_command_list(api):
178177
cmds = []

0 commit comments

Comments
 (0)