Revision b46307af
b/kamaki/cli/__init__.py | ||
---|---|---|
57 | 57 |
from .utils import bold, magenta, red, yellow, print_list, print_dict |
58 | 58 |
from .command_tree import CommandTree |
59 | 59 |
from argument import _arguments, parse_known_args |
60 |
from .history import History |
|
60 | 61 |
|
61 | 62 |
cmd_spec_locations = [ |
62 | 63 |
'kamaki.cli.commands', |
... | ... | |
187 | 188 |
|
188 | 189 |
def load_group_package(group, reload_package=False): |
189 | 190 |
spec_pkg = _arguments['config'].value.get(group, 'cli') |
191 |
if spec_pkg is None: |
|
192 |
return None |
|
190 | 193 |
for location in cmd_spec_locations: |
191 | 194 |
location += spec_pkg if location == '' else ('.'+spec_pkg) |
192 | 195 |
try: |
... | ... | |
246 | 249 |
_help = False |
247 | 250 |
_verbose = False |
248 | 251 |
try: |
249 |
|
|
250 | 252 |
exe = basename(argv[0]) |
251 | 253 |
parser = _init_parser(exe) |
252 | 254 |
parsed, unparsed = parse_known_args(parser) |
253 |
_history = _arguments['history'] |
|
254 |
if _history.value: |
|
255 |
cmd_list = [term for term in argv if term not in _history.parsed_name] |
|
256 |
print_list(_history.get(' '.join(cmd_list))) |
|
257 |
_arguments['history'].add(' '.join(argv)) |
|
258 |
exit(0) |
|
259 |
_arguments['history'].add(' '.join(argv)) |
|
255 |
_history = History(_arguments['config'].get('history', 'file')) |
|
256 |
_history.add(' '.join([exe]+argv[1:])) |
|
260 | 257 |
_debug = _arguments['debug'].value |
261 | 258 |
_help = _arguments['help'].value |
262 | 259 |
_verbose = _arguments['verbose'].value |
b/kamaki/cli/argument.py | ||
---|---|---|
205 | 205 |
silent = FlagArgument('Do not output anything', ('-s', '--silent')), |
206 | 206 |
verbose = FlagArgument('More info at response', ('-v', '--verbose')), |
207 | 207 |
version = VersionArgument('Print current version', ('-V', '--version')), |
208 |
options = CmdLineConfigArgument(_config_arg, 'Override a config value', ('-o', '--options')), |
|
209 |
history = HistoryArgument('Show user (prefixed) history', '--history') |
|
208 |
options = CmdLineConfigArgument(_config_arg, 'Override a config value', ('-o', '--options')) |
|
210 | 209 |
) |
211 | 210 |
|
212 | 211 |
def parse_known_args(parser): |
b/kamaki/cli/commands/pithos_cli.py | ||
---|---|---|
37 | 37 |
from kamaki.cli.utils import format_size, print_dict, pretty_keys, print_list |
38 | 38 |
from kamaki.cli.argument import FlagArgument, ValueArgument, IntArgument |
39 | 39 |
#set_api_description('store', 'Pithos+ storage commands') |
40 |
API_DESCRIPTION = {'store':'Pithos+ storage commands'}
|
|
40 |
API_DESCRIPTION = dict(store='Pithos+ storage commands')
|
|
41 | 41 |
from kamaki.clients.pithos import PithosClient, ClientError |
42 | 42 |
from colors import bold |
43 | 43 |
from sys import stdout, exit |
b/kamaki/cli/config.py | ||
---|---|---|
60 | 60 |
'config': { |
61 | 61 |
'cli': 'config_cli', |
62 | 62 |
'description': 'Configuration commands' |
63 |
}, |
|
64 |
'history':{ |
|
65 |
'cli':'history_cli', |
|
66 |
'file':'.kamaki.history' |
|
63 | 67 |
} |
64 | 68 |
} |
65 | 69 |
|
Also available in: Unified diff