Commit 451a7992 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Allow general options to run a@ initial kamaki

kamaki -v runs a kamaki shell with verbose on!
parent aa5c0458
......@@ -112,27 +112,31 @@ def _update_best_match(name_terms, prefix=[]):
def command(cmd_tree, prefix='', descedants_depth=1):
"""Load a class as a command
spec_cmd0_cmd1 will be command spec cmd0
@cmd_tree is initialized in cmd_spec file and is the structure
e.g. spec_cmd0_cmd1 will be command spec cmd0
:param cmd_tree: is initialized in cmd_spec file and is the structure
where commands are loaded. Var name should be _commands
@param prefix if given, load only commands prefixed with prefix,
@param descedants_depth is the depth of the tree descedants of the
:param prefix: if given, load only commands prefixed with prefix,
:param descedants_depth: is the depth of the tree descedants of the
prefix command. It is used ONLY if prefix and if prefix is not
a terminal command
:returns: the specified class object
def wrap(cls):
global kloger
cls_name = cls.__name__
if not cmd_tree:
if _debug:
print('Warning: command %s found but not loaded' % cls_name)
kloger.warning('command %s found but not loaded' % cls_name)
return cls
name_terms = cls_name.split('_')
if not _update_best_match(name_terms, prefix):
if _debug:
print('Warning: %s failed to update_best_match' % cls_name)
kloger.warning('%s failed to update_best_match' % cls_name)
return None
global _best_match
......@@ -142,7 +146,7 @@ def command(cmd_tree, prefix='', descedants_depth=1):
if not cmd_tree.has_command(partial): # add partial path
if _debug:
print('Warning: %s failed max_len test' % cls_name)
kloger.warning('%s failed max_len test' % cls_name)
return None
cls.description, sep, cls.long_description\
......@@ -45,11 +45,6 @@ from kamaki.clients import ClientError
def _init_shell(exe_string, parser):
parser.arguments.pop('version', None)
parser.arguments.pop('options', None)
parser.arguments.pop('debug', None)
parser.arguments.pop('verbose', None)
parser.arguments.pop('include', None)
parser.arguments.pop('silent', None)
shell = Shell()
from kamaki import __version__ as version
......@@ -162,6 +157,11 @@ class Shell(Cmd):
cmd_parser = ArgumentParseManager(,
cmd_parser.arguments.pop('options', None)
cmd_parser.arguments.pop('debug', None)
cmd_parser.arguments.pop('verbose', None)
cmd_parser.arguments.pop('include', None)
cmd_parser.arguments.pop('silent', None)
cmd_parser.parser.description =
......@@ -188,6 +188,7 @@ class Shell(Cmd):
for name, arg in instance.arguments.items():
arg.value = getattr(cmd_parser.parsed, name, arg.default)
print('prr: %s' % cmd_parser.unparsed)
......@@ -44,7 +44,9 @@ from kamaki.cli.utils import bold
from sys import stdout
from time import localtime, strftime
from datetime import datetime as dtm
from logging import getLogger
kloger = getLogger('kamaki')
pithos_cmds = CommandTree('store', 'Pithos+ storage commands')
_commands = [pithos_cmds]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment