from .utils import bold, magenta, red, yellow, print_list, print_dict
from .command_tree import CommandTree
from argument import _arguments, parse_known_args
+from .history import History
cmd_spec_locations = [
'kamaki.cli.commands',
def load_group_package(group, reload_package=False):
spec_pkg = _arguments['config'].value.get(group, 'cli')
+ if spec_pkg is None:
+ return None
for location in cmd_spec_locations:
location += spec_pkg if location == '' else ('.'+spec_pkg)
try:
_help = False
_verbose = False
try:
-
exe = basename(argv[0])
parser = _init_parser(exe)
parsed, unparsed = parse_known_args(parser)
- _history = _arguments['history']
- if _history.value:
- cmd_list = [term for term in argv if term not in _history.parsed_name]
- print_list(_history.get(' '.join(cmd_list)))
- _arguments['history'].add(' '.join(argv))
- exit(0)
- _arguments['history'].add(' '.join(argv))
+ _history = History(_arguments['config'].get('history', 'file'))
+ _history.add(' '.join([exe]+argv[1:]))
_debug = _arguments['debug'].value
_help = _arguments['help'].value
_verbose = _arguments['verbose'].value
silent = FlagArgument('Do not output anything', ('-s', '--silent')),
verbose = FlagArgument('More info at response', ('-v', '--verbose')),
version = VersionArgument('Print current version', ('-V', '--version')),
- options = CmdLineConfigArgument(_config_arg, 'Override a config value', ('-o', '--options')),
- history = HistoryArgument('Show user (prefixed) history', '--history')
+ options = CmdLineConfigArgument(_config_arg, 'Override a config value', ('-o', '--options'))
)
def parse_known_args(parser):
from kamaki.cli.utils import format_size, print_dict, pretty_keys, print_list
from kamaki.cli.argument import FlagArgument, ValueArgument, IntArgument
#set_api_description('store', 'Pithos+ storage commands')
-API_DESCRIPTION = {'store':'Pithos+ storage commands'}
+API_DESCRIPTION = dict(store='Pithos+ storage commands')
from kamaki.clients.pithos import PithosClient, ClientError
from colors import bold
from sys import stdout, exit
'config': {
'cli': 'config_cli',
'description': 'Configuration commands'
+ },
+ 'history':{
+ 'cli':'history_cli',
+ 'file':'.kamaki.history'
}
}