Revision 6dfd55cb kamaki/cli/commands/astakos.py
b/kamaki/cli/commands/astakos.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from kamaki.cli import command |
35 | 35 |
from kamaki.clients.astakos import AstakosClient |
36 |
from kamaki.cli.utils import print_dict |
|
36 |
from kamaki.cli.utils import print_dict, print_json
|
|
37 | 37 |
from kamaki.cli.commands import _command_init, errors |
38 | 38 |
from kamaki.cli.command_tree import CommandTree |
39 |
from kamaki.cli.argument import FlagArgument |
|
39 | 40 |
|
40 | 41 |
user_cmds = CommandTree('user', 'Astakos API commands') |
41 | 42 |
_commands = [user_cmds] |
... | ... | |
68 | 69 |
Token can also be provided as a parameter |
69 | 70 |
""" |
70 | 71 |
|
72 |
arguments = dict( |
|
73 |
json_output=FlagArgument('show output in json', ('-j', '--json')) |
|
74 |
) |
|
75 |
|
|
71 | 76 |
@errors.generic.all |
72 | 77 |
@errors.user.authenticate |
73 | 78 |
def _run(self, custom_token=None): |
74 | 79 |
super(self.__class__, self)._run() |
75 |
reply = self.client.authenticate(custom_token)
|
|
76 |
print_dict(reply)
|
|
80 |
printer = print_json if self['json_output'] else print_dict
|
|
81 |
printer(self.client.authenticate(custom_token))
|
|
77 | 82 |
|
78 | 83 |
def main(self, custom_token=None): |
79 | 84 |
self._run(custom_token) |
Also available in: Unified diff