Revision 545c6c29 kamaki/cli/commands/__init__.py
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
45 | 45 |
arguments.update(self.arguments) |
46 | 46 |
if isinstance(self, _optional_output_cmd): |
47 | 47 |
arguments.update(self.oo_arguments) |
48 |
if isinstance(self, _optional_json): |
|
49 |
arguments.update(self.oj_arguments) |
|
48 | 50 |
self.arguments = dict(arguments) |
49 | 51 |
try: |
50 | 52 |
self.config = self['config'] |
... | ... | |
129 | 131 |
return self[argterm] |
130 | 132 |
|
131 | 133 |
|
134 |
# feature classes - inherit them to get special features for your commands |
|
135 |
|
|
136 |
|
|
132 | 137 |
class _optional_output_cmd(object): |
133 | 138 |
|
134 | 139 |
oo_arguments = dict( |
... | ... | |
141 | 146 |
print_json(r) |
142 | 147 |
elif self['with_output']: |
143 | 148 |
print_items([r] if isinstance(r, dict) else r) |
149 |
|
|
150 |
|
|
151 |
class _optional_json(object): |
|
152 |
|
|
153 |
oj_arguments = dict( |
|
154 |
json_output=FlagArgument('show headers in json', ('-j', '--json')) |
|
155 |
) |
|
156 |
|
|
157 |
def _print(self, output, print_method=print_items, **print_method_kwargs): |
|
158 |
if self['json_output']: |
|
159 |
print_json(output) |
|
160 |
else: |
|
161 |
print_method(output, **print_method_kwargs) |
Also available in: Unified diff