diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-12-11 11:58:29 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-12-11 11:58:32 +0000 |
commit | faff3244108dae2d1469f83c00eb74f8bacced77 (patch) | |
tree | 9fa475dbcf0e7fcd725cd2a9de233e90dbd4273a | |
parent | 4b1fcab140d940470c342c6857cdc8682406f0b7 (diff) | |
download | lorry-controller-sam/cli.tar.gz |
Add tiny prototype of a command-line interface for lorry-controllersam/cli
I can never remember how the HTTP API works and users really shouldn't
have to deal with it directly.
-rw-r--r-- | lorryctl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lorryctl b/lorryctl new file mode 100644 index 0000000..1be9341 --- /dev/null +++ b/lorryctl @@ -0,0 +1,25 @@ +# Prototype lorry-controller cli, to save remembering the HTTP API... + + +import cliapp +import requests + + +class CLI(cliapp.Application): + def cmd_promote(self, args): + '''Move a repo to the top of the processing queue.''' + + if len(args) != 1: + raise cliapp.AppException( + 'This command takes one argument: the repo to promote.') + + url = 'http://localhost:12765/1.0/move-to-top' + payload = {'path': args[0]} + r = requests.post(url, data=payload) + if r.ok: + print r.text + else: + raise cliapp.AppException(r) + + +CLI().run() |