Skip to content

Commit 56d0d30

Browse files
author
Gabriel Monroy
committed
finish adding docstrings and inline help to cli, add support for enumerating releases/builds #16
1 parent ef89938 commit 56d0d30

1 file changed

Lines changed: 111 additions & 33 deletions

File tree

client/deis.py

Lines changed: 111 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
55
Usage: deis <command> [--formation <formation>] [<args>...]
66
7-
Options:
8-
-h --help Show this help screen
9-
-v --version Show the CLI version
10-
117
Auth commands:
128
139
register register a new user with a controller
@@ -24,7 +20,7 @@
2420
calculate recalculate and update the formation databag
2521
destroy destroy a container formation
2622
27-
Use `deis help [subcommand]` to learn about these subcommands:
23+
Infrastructure commands:
2824
2925
formations manage container formations
3026
layers manage layers of nodes
@@ -39,8 +35,8 @@
3935
builds manage git-push builds for a formation
4036
releases manage a formation's release history
4137
42-
Use `git push deis master` to deploy to the container formation.
43-
38+
Use `git push deis master` to deploy to a formation.
39+
Use `deis help [command]` to learn more.
4440
"""
4541

4642
from cookielib import MozillaCookieJar
@@ -338,7 +334,12 @@ def auth_logout(self, args):
338334

339335
def builds(self, args):
340336
"""
341-
Builds help would be nice
337+
Valid commands for builds:
338+
339+
builds:list list build history for a formation
340+
builds:create create a new build for a formation
341+
342+
Use `deis help [command]` to learn more
342343
"""
343344
return self.builds_list(args)
344345

@@ -382,7 +383,13 @@ def builds_list(self, args):
382383

383384
def config(self, args):
384385
"""
385-
Config help would be nice
386+
Valid commands for config:
387+
388+
config:list list environment variables for a formation
389+
config:set set environment variables for a formation
390+
config:unset unset environment variables for a formation
391+
392+
Use `deis help [command]` to learn more
386393
"""
387394
return self.config_list(args)
388395

@@ -411,7 +418,7 @@ def config_list(self, args):
411418

412419
def config_set(self, args):
413420
"""
414-
Set environment variables on a formation
421+
Set environment variables for a formation
415422
416423
Usage: deis config:set <var>=<value>...
417424
"""
@@ -437,7 +444,7 @@ def config_set(self, args):
437444

438445
def config_unset(self, args):
439446
"""
440-
Unset an environment variable on a formation
447+
Unset an environment variable for a formation
441448
442449
Usage: deis config:unset <key>...
443450
"""
@@ -466,7 +473,12 @@ def config_unset(self, args):
466473

467474
def containers(self, args):
468475
"""
469-
Containers help would be nice
476+
Valid commands for containers:
477+
478+
containers:list list containers for a formation
479+
containers:scale scale a formation's containers (i.e web=4 worker=2)
480+
481+
Use `deis help [command]` to learn more
470482
"""
471483
return self.containers_list(args)
472484

@@ -523,7 +535,14 @@ def containers_scale(self, args):
523535

524536
def flavors(self, args):
525537
"""
526-
Flavors help would be nice
538+
Valid commands for flavors:
539+
540+
flavors:create create a new node flavor
541+
flavors:info print information about a node flavor
542+
flavors:list list available flavors
543+
flavors:delete delete a node flavor
544+
545+
Use `deis help [command]` to learn more
527546
"""
528547
return self.flavors_list(args)
529548

@@ -593,7 +612,17 @@ def flavors_list(self, args):
593612

594613
def formations(self, args):
595614
"""
596-
Formations help would be nice
615+
Valid commands for formations:
616+
617+
formations:create create a new container formation
618+
formations:info print a represenation of the formation
619+
formations:scale scale container types (web=2, worker=1)
620+
formations:balance rebalance the container formation
621+
formations:converge force-converge all nodes in the formation
622+
formations:calculate recalculate and update the formation databag
623+
formations:destroy destroy a container formation
624+
625+
Use `deis help [command]` to learn more
597626
"""
598627
return self.formations_list(args)
599628

@@ -641,7 +670,7 @@ def formations_create(self, args):
641670
print
642671
self.layers_create({'<id>': 'runtime', '<flavor>': flavor})
643672
self.layers_create({'<id>': 'proxy', '<flavor>': flavor})
644-
print('\nUse `deis layers:scale runtime=1 proxy=1` to scale a basic formation')
673+
print('\nUse `deis layers:scale proxy=1 runtime=1` to scale a basic formation')
645674
else:
646675
print('Error!', response.text)
647676

@@ -778,7 +807,13 @@ def formations_converge(self, args):
778807

779808
def keys(self, args):
780809
"""
781-
Keys help would be nice
810+
Valid commands for SSH keys:
811+
812+
keys:list list SSH keys for the logged in user
813+
keys:add add an SSH key
814+
keys:remove remove an SSH key
815+
816+
Use `deis help [command]` to learn more
782817
"""
783818
return self.keys_list(args)
784819

@@ -856,7 +891,14 @@ def keys_remove(self, args):
856891

857892
def layers(self, args):
858893
"""
859-
Layers help would be nice
894+
Valid commands for node layers:
895+
896+
layers:create create a layer of nodes for a formation
897+
layers:scale scale nodes in a layer (e.g. proxy=1 runtime=2)
898+
layers:list list layers in a formation
899+
layers:destroy destroy a layer of nodes in a formation
900+
901+
Use `deis help [command]` to learn more
860902
"""
861903
return self.layers_list(args)
862904

@@ -971,7 +1013,13 @@ def layers_scale(self, args):
9711013

9721014
def nodes(self, args):
9731015
"""
974-
Nodes help would be nice
1016+
Valid commands for nodes:
1017+
1018+
nodes:list list nodes for a formation
1019+
nodes:info print info for a given node
1020+
nodes:destroy destroy a node by ID
1021+
1022+
Use `deis help [command]` to learn more
9751023
"""
9761024
return self.nodes_list(args)
9771025

@@ -1038,7 +1086,14 @@ def nodes_destroy(self, args):
10381086

10391087
def providers(self, args):
10401088
"""
1041-
Providers help would be nice
1089+
Valid commands for providers:
1090+
1091+
providers:list list available providers for the logged in user
1092+
providers:discover discover provider credentials using envvars
1093+
providers:create create a new provider for use by deis
1094+
providers:info print information about a specific provider
1095+
1096+
Use `deis help [command]` to learn more
10421097
"""
10431098
return self.providers_list(args)
10441099

@@ -1110,6 +1165,19 @@ def providers_discover(self, args):
11101165
print 'No credentials discovered, did you install the EC2 Command Line tools?'
11111166
return
11121167

1168+
def providers_info(self, args):
1169+
"""
1170+
Print information about a specific provider
1171+
1172+
Usage: deis providers:info <provider>
1173+
"""
1174+
provider = args.get('<provider>')
1175+
response = self._dispatch('get', "/api/providers/{}".format(provider))
1176+
if response.status_code == requests.codes.ok: # @UndefinedVariable
1177+
print(json.dumps(response.json(), indent=2))
1178+
else:
1179+
print('Error!', response.text)
1180+
11131181
def providers_list(self, args):
11141182
"""
11151183
List providers for the logged in user
@@ -1124,25 +1192,35 @@ def providers_list(self, args):
11241192
else:
11251193
print('Error!', response.text)
11261194

1127-
def providers_info(self, args):
1195+
def releases(self, args):
11281196
"""
1129-
Print information about a specific provider
1197+
Valid commands for releases:
11301198
1131-
Usage: deis providers:info <provider>
1199+
releases:list list a formation's release history
1200+
releases:info print information about a specific release
1201+
releases:rollback coming soon!
1202+
1203+
Use `deis help [command]` to learn more
11321204
"""
1133-
provider = args.get('<provider>')
1134-
response = self._dispatch('get', "/api/providers/{}".format(provider))
1205+
return self.releases_list(args)
1206+
1207+
def releases_info(self, args):
1208+
"""
1209+
Print info about a particular release
1210+
1211+
Usage: deis releases:info <version>
1212+
"""
1213+
version = args.get('<version>')
1214+
formation = args.get('--formation')
1215+
if not formation:
1216+
formation = self._session.formation
1217+
response = self._dispatch(
1218+
'get', "/api/formations/{formation}/releases/{version}".format(**locals()))
11351219
if response.status_code == requests.codes.ok: # @UndefinedVariable
11361220
print(json.dumps(response.json(), indent=2))
11371221
else:
11381222
print('Error!', response.text)
11391223

1140-
def releases(self, args):
1141-
"""
1142-
Releases help would be nice
1143-
"""
1144-
return self.releases_list(args)
1145-
11461224
def releases_list(self, args):
11471225
"""
11481226
List release history for a formation
@@ -1152,12 +1230,12 @@ def releases_list(self, args):
11521230
formation = args.get('--formation')
11531231
if not formation:
11541232
formation = self._session.formation
1155-
response = self._dispatch('get', '/api/formations/{}/release'.format(formation))
1233+
response = self._dispatch('get', '/api/formations/{formation}/releases'.format(**locals()))
11561234
if response.status_code == requests.codes.ok: # @UndefinedVariable
1157-
print('=== {0}'.format(formation))
1235+
print('=== {0} Releases'.format(formation))
11581236
data = response.json()
11591237
for item in data['results']:
1160-
print('{0[uuid]:<23} {0[created]}'.format(item))
1238+
print('{version} {created}'.format(**item))
11611239
else:
11621240
print('Error!', response.text)
11631241

0 commit comments

Comments
 (0)