Commit 9b3c8fd9 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Fix required args parsing in kamaki shell mode

parent b8b1e2f8
......@@ -452,7 +452,8 @@ class ArgumentParseManager(object):
def __init__(
self, exe,
arguments=None, required=None, syntax=None, description=None):
arguments=None, required=None, syntax=None, description=None,
:param exe: (str) the basic command (e.g. 'kamaki')
......@@ -473,13 +474,15 @@ class ArgumentParseManager(object):
:param syntax: (str) The basic syntax of the arguments. Default:
exe <cmd_group> [<cmd_subbroup> ...] <cmd>
:param description: (str) The description of the commands or ''
:param check_required: (bool) Set to False inorder not to check for
required argument values while parsing
self.parser = ArgumentParser(
add_help=False, formatter_class=RawDescriptionHelpFormatter)
self._exe = exe
self.syntax = syntax or (
'%s <cmd_group> [<cmd_subbroup> ...] <cmd>' % exe)
self.required = required
self.required, self.check_required = required, check_required
self.parser.description = description or ''
if arguments:
self.arguments = arguments
......@@ -613,7 +616,7 @@ class ArgumentParseManager(object):
def _parse_required_arguments(self, required, parsed_args):
if not required:
if not (self.check_required and required):
return True
if isinstance(required, tuple):
for item in required:
......@@ -175,10 +175,9 @@ class Shell(Cmd):
tmp_args.pop('verbose', None)
tmp_args.pop('silent', None)
tmp_args.pop('config', None)
print 'YOLO >>>\n\t', '\n\t'.join([
('%s %s %s' % k, v, v.value) for k, v in args.items()])
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):
......@@ -252,7 +252,7 @@ class OutputFormatArgument(ValueArgument):
def value(self):
return self._value
return getattr(self, '_value', None)
def value(self, newvalue):
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