# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.command
-from kamaki.cli import command
+from kamaki.cli.new import command
from kamaki.clients.astakos import AstakosClient, ClientError
from kamaki.cli.utils import print_dict
from kamaki.cli.errors import raiseCLIError
from kamaki.cli.commands import _command_init
+from kamaki.cli.command_tree import CommandTree
-
-API_DESCRIPTION = {'astakos': 'Astakos API commands'}
+astakos_commands = CommandTree('astakos', 'Astakos API commands')
+_commands = [astakos_commands]
class _astakos_init(_command_init):
self.client = AstakosClient(base_url=base_url, token=token)
-@command()
+@command(_commands)
class astakos_authenticate(_astakos_init):
"""Authenticate a user"""
for location in cmd_spec_locations:
location += spec_name if location == '' else '.%s' % spec_name
try:
+ print('\t-- %s' % location)
pkg = __import__(location, fromlist=[module])
+ print('SO COOL')
+ return pkg
except ImportError:
continue
return pkg
return 1
+def set_command_param(param, value):
+ if param == 'prefix':
+ pos = 0
+ elif param == 'descedants_depth':
+ pos = 1
+ else:
+ return
+ global command
+ def_params = list(command.func_defaults)
+ def_params[pos] = value
+ command.func_defaults = tuple(def_params)
+
+
def one_cmd(parser, unparsed, arguments):
group = get_command_group(list(unparsed), arguments)
if not group:
_groups_help(arguments)
exit(0)
- global command
- def_params = list(command.func_defaults)
- def_params[0] = unparsed
- command.func_defaults = tuple(def_params)
+ set_command_param(
+ 'prefix',
+ [term for term in unparsed if not term.startswith('-')]
+ )
global _best_match
_best_match = []
_fix_arguments()
shell = _start_shell()
_config = _arguments['config']
- #_config.value = None
from kamaki.cli.command_tree import CommandTree
shell.cmd_tree = CommandTree(
'kamaki', 'A command line tool for poking clouds')
for spec in [spec for spec in _config.get_groups()\
if arguments['config'].get(spec, 'cli')]:
+ print('SPEC NAME: %s' % spec)
try:
- print('TRY(%s)' % spec)
+ print('\t1')
spec_module = _load_spec_module(spec, arguments, '_commands')
- print('\t- %s' % spec_module)
+ print('\t2 %s' % spec_module)
spec_commands = getattr(spec_module, '_commands')
- print('\t- %s' % spec_commands)
+ print('\t3')
except AttributeError:
if _debug:
print('Warning: No valid description for %s' % spec)
continue
for spec_tree in spec_commands:
- shell.cmd_tree.add_tree(spec_tree)
+ if spec_tree.name == spec:
+ shell.cmd_tree.add_tree(spec_tree)
+ break
shell.run()