Revision c8e17a67
b/kamaki/cli/argument.py | ||
---|---|---|
231 | 231 |
try: |
232 | 232 |
self._value = int(newvalue) |
233 | 233 |
except ValueError: |
234 |
raiseCLIError(CLISyntaxError('IntArgument Error'),
|
|
235 |
details='Value %s not an int' % newvalue)
|
|
234 |
raiseCLIError(CLISyntaxError('IntArgument Error', |
|
235 |
details=['Value %s not an int' % newvalue]))
|
|
236 | 236 |
|
237 | 237 |
|
238 | 238 |
class VersionArgument(FlagArgument): |
... | ... | |
444 | 444 |
|
445 | 445 |
def parse(self, new_args=None): |
446 | 446 |
"""Do parse user input""" |
447 |
if new_args: |
|
448 |
self._parsed, unparsed = self.parser.parse_known_args(new_args) |
|
449 |
else: |
|
450 |
self._parsed, unparsed = self.parser.parse_known_args() |
|
447 |
try: |
|
448 |
if new_args: |
|
449 |
self._parsed, unparsed = self.parser.parse_known_args(new_args) |
|
450 |
else: |
|
451 |
self._parsed, unparsed = self.parser.parse_known_args() |
|
452 |
except SystemExit: |
|
453 |
# deal with the fact that argparse error system is STUPID |
|
454 |
raiseCLIError(CLISyntaxError('Argument Syntax Error')) |
|
451 | 455 |
for name, arg in self.arguments.items(): |
452 | 456 |
arg.value = getattr(self._parsed, name, arg.default) |
453 | 457 |
self._unparsed = [] |
b/kamaki/cli/command_shell.py | ||
---|---|---|
167 | 167 |
|
168 | 168 |
# exec command or change context |
169 | 169 |
if subcmd.is_command: # exec command |
170 |
cls = subcmd.get_class() |
|
171 |
ldescr = getattr(cls, 'long_description', '') |
|
172 |
if subcmd.path == 'history_run': |
|
173 |
instance = cls(dict(cmd_parser.arguments), self.cmd_tree) |
|
174 |
else: |
|
175 |
instance = cls(dict(cmd_parser.arguments)) |
|
176 |
cmd_parser.update_arguments(instance.arguments) |
|
177 |
instance.arguments.pop('config') |
|
178 |
cmd_parser.arguments = instance.arguments |
|
179 |
cmd_parser.syntax = '%s %s' % ( |
|
180 |
subcmd.path.replace('_', ' '), cls.syntax) |
|
181 |
if '-h' in cmd_args or '--help' in cmd_args: |
|
182 |
cmd_parser.parser.print_help() |
|
183 |
if ldescr: |
|
184 |
print('\nDetails:') |
|
185 |
print('%s' % ldescr) |
|
186 |
return |
|
187 |
cmd_parser.parse(cmd_args) |
|
188 |
|
|
189 |
for name, arg in instance.arguments.items(): |
|
190 |
arg.value = getattr(cmd_parser.parsed, name, arg.default) |
|
191 |
|
|
192 | 170 |
try: |
171 |
cls = subcmd.get_class() |
|
172 |
ldescr = getattr(cls, 'long_description', '') |
|
173 |
if subcmd.path == 'history_run': |
|
174 |
instance = cls(dict(cmd_parser.arguments), |
|
175 |
self.cmd_tree) |
|
176 |
else: |
|
177 |
instance = cls(dict(cmd_parser.arguments)) |
|
178 |
cmd_parser.update_arguments(instance.arguments) |
|
179 |
instance.arguments.pop('config') |
|
180 |
cmd_parser.arguments = instance.arguments |
|
181 |
cmd_parser.syntax = '%s %s' % ( |
|
182 |
subcmd.path.replace('_', ' '), cls.syntax) |
|
183 |
if '-h' in cmd_args or '--help' in cmd_args: |
|
184 |
cmd_parser.parser.print_help() |
|
185 |
if ldescr.strip(): |
|
186 |
print('\nDetails:') |
|
187 |
print('%s' % ldescr) |
|
188 |
return |
|
189 |
cmd_parser.parse(cmd_args) |
|
190 |
|
|
191 |
for name, arg in instance.arguments.items(): |
|
192 |
arg.value = getattr(cmd_parser.parsed, name, |
|
193 |
arg.default) |
|
194 |
|
|
193 | 195 |
exec_cmd(instance, |
194 | 196 |
cmd_parser.unparsed, |
195 | 197 |
cmd_parser.parser.print_help) |
b/kamaki/cli/commands/pithos_cli.py | ||
---|---|---|
402 | 402 |
show_only_shared=self.get_argument('shared')) |
403 | 403 |
self.print_objects(r.json) |
404 | 404 |
except ClientError as err: |
405 |
if err.status == 404\ |
|
406 |
and 'Container does not exist' in getattr(err, 'message', ''): |
|
407 |
raiseCLIError(err, 'No container %s in account %s' % ( |
|
408 |
self.container, self.account), |
|
409 |
details=self.generic_err_details) |
|
405 |
if err.status == 404: |
|
406 |
if 'Container does not exist' in ('%s' % err): |
|
407 |
raiseCLIError(err, 'No container %s in account %s'\ |
|
408 |
% (self.container, self.account), |
|
409 |
details=self.generic_err_details) |
|
410 |
elif 'Object does not exist' in ('%s' % err): |
|
411 |
raiseCLIError(err, 'No object %s in %s\'s container %s'\ |
|
412 |
% (self.path, self.account, self.container), |
|
413 |
details=self.generic_err_details) |
|
410 | 414 |
raiseCLIError(err) |
411 | 415 |
|
412 | 416 |
|
b/kamaki/cli/one_command.py | ||
---|---|---|
97 | 97 |
parser.update_arguments(executable.arguments) |
98 | 98 |
#parsed, unparsed = parse_known_args(parser, executable.arguments) |
99 | 99 |
for term in _best_match: |
100 |
parser.unparsed.remove(term) |
|
100 |
parser.unparsed.remove(term)
|
|
101 | 101 |
exec_cmd(executable, parser.unparsed, parser.parser.print_help) |
Also available in: Unified diff