Skip to content

Commit 7367202

Browse files
author
Matthew Fisher
committed
Merge pull request #3177 from bacongobbler/proposal-deis-client-plugins
Proposal: deis client plugins
2 parents 1a6fb79 + 27379c7 commit 7367202

3 files changed

Lines changed: 48 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:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
:title: CLI Plugins
2+
:description: How to manage plugins for the Deis CLI.
3+
4+
.. _cli_plugins:
5+
6+
CLI Plugins
7+
===========
8+
9+
Plugins allow developers to extend the functionality of the :ref:`Deis Client <install-client>`,
10+
adding new commands or features.
11+
12+
If an unknown command is specified, the Client will attempt to execute the command as a
13+
dash-separated command. In this case, ``deis resource:command`` will execute ``deis-resource`` with
14+
the argument list ``command``. In full form:
15+
16+
.. code-block:: console
17+
18+
$ # these two are identical
19+
$ deis accounts:list
20+
$ deis-accounts list
21+
22+
Any flags after the command will also be sent to the plugin as an argument:
23+
24+
.. code-block:: console
25+
26+
$ # these two are identical
27+
$ deis accounts:list --debug
28+
$ deis-accounts list --debug
29+
30+
But flags preceeding the command will not:
31+
32+
.. code-block:: console
33+
34+
$ # these two are identical
35+
$ deis --debug accounts:list
36+
$ deis-accounts list

docs/customizing_deis/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Customizing Deis
1111

1212
.. toctree::
1313

14+
cli-plugins
1415
builder_settings
1516
cache_settings
1617
controller_settings

0 commit comments

Comments
 (0)