Skip to content

Commit 27379c7

Browse files
author
Matthew Fisher
committed
feat(client): add client extensions
If an unknown command is specified, the client will attempt to execute the command as a dash-separated command. If the command cannot be found, The original usage message is returned. This opens the opportunity to add and install extensions to the deis client by simply installing a plugin onto the operating system.
1 parent fb858d9 commit 27379c7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

client/deis.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,17 @@ def main():
22082208
if hasattr(cli, cmd):
22092209
method = getattr(cli, cmd)
22102210
else:
2211-
raise DocoptExit('Found no matching command, try `deis help`')
2211+
# split by : to execute the proper command
2212+
split_cmd = args['<command>'].split(':')
2213+
dash_separated_command = 'deis-{}'.format(split_cmd[0])
2214+
arglist = args['<args>']
2215+
if len(split_cmd) > 1:
2216+
# safety precaution in case users want to use more than one colon in their command
2217+
arglist = split_cmd[1:] + arglist
2218+
try:
2219+
sys.exit(subprocess.call([dash_separated_command] + arglist))
2220+
except OSError:
2221+
raise DocoptExit('Found no matching command, try `deis help`')
22122222
# re-parse docopt with the relevant docstring
22132223
docstring = trim(getattr(cli, cmd).__doc__)
22142224
if 'Usage: ' in docstring:

0 commit comments

Comments
 (0)