Skip to content

Commit af4b082

Browse files
author
Gabriel Monroy
committed
add subcommand help dispatch, with placeholder help for now #16
1 parent c3e907c commit af4b082

1 file changed

Lines changed: 78 additions & 5 deletions

File tree

client/deis.py

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def auth_register(self, args):
246246

247247
def auth_login(self, args):
248248
"""
249-
Authenticate a user in the system.
249+
Login by authenticating against a controller
250250
251251
Usage: deis auth:login <controller> [--username=<username> --password=<password>]
252252
"""
@@ -276,7 +276,11 @@ def auth_login(self, args):
276276
return False
277277

278278
def auth_logout(self, args):
279-
"""Clear a user's session and unauthenticate her."""
279+
"""
280+
Logout from a controller, clearing the user session
281+
282+
Usage: deis auth:logout
283+
"""
280284
controller = self._settings.get('controller')
281285
if controller:
282286
self._dispatch('get', '/api/auth/logout/')
@@ -286,6 +290,12 @@ def auth_logout(self, args):
286290
self._settings.save()
287291
print('Logged out')
288292

293+
def builds(self, args):
294+
"""
295+
Builds help would be nice
296+
"""
297+
return self.builds_list(args)
298+
289299
def builds_create(self, args):
290300
"""
291301
Usage: deis builds:create - [--formation=<formation>]
@@ -320,6 +330,12 @@ def builds_list(self, args):
320330
else:
321331
print('Error!', response.text)
322332

333+
def config(self, args):
334+
"""
335+
Config help would be nice
336+
"""
337+
return self.config_list(args)
338+
323339
def config_list(self, args):
324340
"""
325341
Usage: deis config:list
@@ -392,6 +408,12 @@ def config_unset(self, args):
392408
else:
393409
print('Error!', response.text)
394410

411+
def containers(self, args):
412+
"""
413+
Containers help would be nice
414+
"""
415+
return self.containers_list(args)
416+
395417
def containers_list(self, args):
396418
"""
397419
Usage: deis containers:list
@@ -437,6 +459,12 @@ def containers_scale(self, args):
437459
else:
438460
print('Error!', response.text)
439461

462+
def flavors(self, args):
463+
"""
464+
Flavors help would be nice
465+
"""
466+
return self.flavors_list(args)
467+
440468
def flavors_create(self, args):
441469
"""
442470
Usage: deis flavors:create --id=<id> --provider=<provider> --params=<params> [options]
@@ -493,6 +521,12 @@ def flavors_list(self, args):
493521
else:
494522
print('Error!', response.text)
495523

524+
def formations(self, args):
525+
"""
526+
Formations help would be nice
527+
"""
528+
return self.formations_list(args)
529+
496530
def formations_create(self, args):
497531
"""
498532
Usage: deis formations:create [--id=<id> --flavor=<flavor>]
@@ -638,6 +672,12 @@ def formations_converge(self, args):
638672
else:
639673
print('Error!', response.text)
640674

675+
def keys(self, args):
676+
"""
677+
Keys help would be nice
678+
"""
679+
return self.keys_list(args)
680+
641681
def keys_add(self, args):
642682
"""
643683
Usage: deis keys:add [<key>]
@@ -708,6 +748,12 @@ def keys_remove(self, args):
708748
else:
709749
print('Error!', response.text)
710750

751+
def layers(self, args):
752+
"""
753+
Layers help would be nice
754+
"""
755+
return self.layers_list(args)
756+
711757
def layers_create(self, args):
712758
"""
713759
Create a layer of nodes.
@@ -823,6 +869,12 @@ def nodes_info(self, args):
823869
else:
824870
print('Error!', response.text)
825871

872+
def nodes(self, args):
873+
"""
874+
Nodes help would be nice
875+
"""
876+
return self.nodes_list(args)
877+
826878
def nodes_list(self, args):
827879
"""
828880
List nodes for this formation.
@@ -862,6 +914,12 @@ def nodes_destroy(self, args):
862914
else:
863915
print('Error!', response.status_code, response.text)
864916

917+
def providers(self, args):
918+
"""
919+
Providers help would be nice
920+
"""
921+
return self.providers_list(args)
922+
865923
def providers_create(self, args):
866924
"""
867925
Create a provider for use by Deis
@@ -943,6 +1001,21 @@ def providers_info(self, args):
9431001
else:
9441002
print('Error!', response.text)
9451003

1004+
def releases_list(self, args):
1005+
"""
1006+
Usage: deis releases:list
1007+
"""
1008+
formation = args.get('--formation')
1009+
if not formation:
1010+
formation = self._session.formation
1011+
response = self._dispatch('get', '/formations/{}/release'.format(formation))
1012+
if response.status_code == requests.codes.ok: # @UndefinedVariable
1013+
print('=== {0}'.format(formation))
1014+
data = response.json()
1015+
for item in data['results']:
1016+
print('{0[uuid]:<23} {0[created]}'.format(item))
1017+
else:
1018+
print('Error!', response.text)
9461019

9471020
def main():
9481021
"""
@@ -982,12 +1055,12 @@ def main():
9821055
args.update(docopt(docstring))
9831056
# find the right method for dispatching
9841057
if cmd == 'help':
1058+
if len(sys.argv) == 3 and sys.argv[2] in dir(cli):
1059+
print trim(getattr(cli, sys.argv[2]).__doc__)
1060+
return
9851061
docopt(__doc__, argv=['--help'])
9861062
elif hasattr(cli, cmd):
9871063
method = getattr(cli, cmd)
988-
# magically call list if no subcommand provided
989-
elif hasattr(cli, cmd + '_list'):
990-
method = getattr(cli, cmd + '_list')
9911064
else:
9921065
print 'Found no matching command'
9931066
raise DocoptExit()

0 commit comments

Comments
 (0)