Revision 320aac17
b/kamaki/cli/__init__.py | ||
---|---|---|
340 | 340 |
global _debug |
341 | 341 |
global kloger |
342 | 342 |
descriptions = {} |
343 |
acceptable_groups = arguments['config'].get_groups() |
|
343 | 344 |
for cmd_group, spec in arguments['config'].get_cli_specs(): |
344 | 345 |
pkg = _load_spec_module(spec, arguments, '_commands') |
345 | 346 |
if pkg: |
346 | 347 |
cmds = getattr(pkg, '_commands') |
347 | 348 |
try: |
348 | 349 |
for cmd in cmds: |
349 |
descriptions[cmd.name] = cmd.description |
|
350 |
if cmd.name in acceptable_groups: |
|
351 |
descriptions[cmd.name] = cmd.description |
|
350 | 352 |
except TypeError: |
351 | 353 |
if _debug: |
352 | 354 |
kloger.warning( |
b/kamaki/cli/argument.py | ||
---|---|---|
442 | 442 |
the parsers arguments specification |
443 | 443 |
""" |
444 | 444 |
self.parser = ArgumentParser( |
445 |
add_help=False, |
|
446 |
formatter_class=RawDescriptionHelpFormatter) |
|
445 |
add_help=False, formatter_class=RawDescriptionHelpFormatter) |
|
447 | 446 |
self.syntax = '%s <cmd_group> [<cmd_subbroup> ...] <cmd>' % exe |
448 | 447 |
if arguments: |
449 | 448 |
self.arguments = arguments |
... | ... | |
513 | 512 |
self.update_parser() |
514 | 513 |
|
515 | 514 |
def parse(self, new_args=None): |
516 |
"""Do parse user input"""
|
|
515 |
"""Parse user input"""
|
|
517 | 516 |
try: |
518 |
if new_args: |
|
519 |
self._parsed, unparsed = self.parser.parse_known_args(new_args) |
|
520 |
else: |
|
521 |
self._parsed, unparsed = self.parser.parse_known_args() |
|
517 |
pkargs = (new_args,) if new_args else () |
|
518 |
self._parsed, unparsed = self.parser.parse_known_args(*pkargs) |
|
522 | 519 |
except SystemExit: |
523 |
# deal with the fact that argparse error system is STUPID |
|
524 | 520 |
raiseCLIError(CLISyntaxError('Argument Syntax Error')) |
525 | 521 |
for name, arg in self.arguments.items(): |
526 | 522 |
arg.value = getattr(self._parsed, name, arg.default) |
b/kamaki/cli/command_shell.py | ||
---|---|---|
310 | 310 |
else: |
311 | 311 |
intro = self.cmd_tree.name |
312 | 312 |
|
313 |
acceptable = parser.arguments['config'].get_groups() |
|
314 |
total = self.cmd_tree.get_group_names() |
|
315 |
self.cmd_tree.exclude(set(total).difference(acceptable)) |
|
316 |
|
|
313 | 317 |
for subcmd in self.cmd_tree.get_subcommands(path): |
314 | 318 |
self._register_command(subcmd.path) |
315 | 319 |
|
b/kamaki/cli/command_tree.py | ||
---|---|---|
137 | 137 |
self.name = name |
138 | 138 |
self.description = description |
139 | 139 |
|
140 |
def exclude(self, groups_to_exclude=[]): |
|
141 |
for group in groups_to_exclude: |
|
142 |
self.groups.pop(group, None) |
|
143 |
|
|
140 | 144 |
def add_command(self, command_path, description=None, cmd_class=None): |
141 | 145 |
terms = command_path.split('_') |
142 | 146 |
try: |
b/kamaki/cli/config.py | ||
---|---|---|
88 | 88 |
# Optional command specs: |
89 | 89 |
# 'livetest_cli': 'livetest', |
90 | 90 |
# 'astakos_cli': 'snf-astakos' |
91 |
# 'floating_cli': 'cyclades' |
|
91 | 92 |
}, |
92 | 93 |
CLOUD_PREFIX: |
93 | 94 |
{ |
Also available in: Unified diff