Update copyright dates for changes files
[kamaki] / kamaki / cli / command_shell.py
index c6f3305..b9391bc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2012-2013 GRNET S.A. All rights reserved.
+# Copyright 2012-2014 GRNET S.A. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or
 # without modification, are permitted provided that the following
 
 from cmd import Cmd
 from os import popen
-from sys import stdout, stderr
+from sys import stdout
 
 from kamaki.cli import exec_cmd, print_error_message, print_subcommands_help
 from kamaki.cli.argument import ArgumentParseManager
-from kamaki.cli.utils import print_dict, split_input
+from kamaki.cli.utils import print_dict, split_input, pref_enc
 from kamaki.cli.history import History
 from kamaki.cli.errors import CLIError
 from kamaki.clients import ClientError
@@ -176,7 +176,8 @@ class Shell(Cmd):
         tmp_args.pop('silent', None)
         tmp_args.pop('config', None)
         help_parser = ArgumentParseManager(
-            cmd_name, tmp_args, required, syntax=syntax, description=descr)
+            cmd_name, tmp_args, required,
+            syntax=syntax, description=descr, check_required=False)
         return help_parser.print_help
 
     def _register_command(self, cmd_path):
@@ -189,6 +190,7 @@ class Shell(Cmd):
                 <cmd> <term> <term> <args> is always parsed to most specific
                 even if cmd_term_term is not a terminal path
             """
+            line = line.decode(pref_enc)
             subcmd, cmd_args = cmd.parse_out(split_input(line))
             self._history.add(' '.join([cmd.path.replace('_', ' '), line]))
             cmd_parser = ArgumentParseManager(
@@ -306,8 +308,9 @@ class Shell(Cmd):
         self.auth_base = auth_base
         self.cloud = cloud
         self._parser = parser
-        self._history = History(
-            parser.arguments['config'].get('global', 'history_file'))
+        cnf = parser.arguments['config']
+        self._history = History(cnf.get('global', 'history_file'))
+        self._history.limit = cnf.get('global', 'history_limit')
         if path:
             cmd = self.cmd_tree.get_command(path)
             intro = cmd.path.replace('_', ' ')