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): ...@@ -452,7 +452,8 @@ class ArgumentParseManager(object):
def __init__( def __init__(
self, exe, 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') :param exe: (str) the basic command (e.g. 'kamaki')
...@@ -473,13 +474,15 @@ class ArgumentParseManager(object): ...@@ -473,13 +474,15 @@ class ArgumentParseManager(object):
:param syntax: (str) The basic syntax of the arguments. Default: :param syntax: (str) The basic syntax of the arguments. Default:
exe <cmd_group> [<cmd_subbroup> ...] <cmd> exe <cmd_group> [<cmd_subbroup> ...] <cmd>
:param description: (str) The description of the commands or '' :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( self.parser = ArgumentParser(
add_help=False, formatter_class=RawDescriptionHelpFormatter) add_help=False, formatter_class=RawDescriptionHelpFormatter)
self._exe = exe self._exe = exe
self.syntax = syntax or ( self.syntax = syntax or (
'%s <cmd_group> [<cmd_subbroup> ...] <cmd>' % exe) '%s <cmd_group> [<cmd_subbroup> ...] <cmd>' % exe)
self.required = required self.required, self.check_required = required, check_required
self.parser.description = description or '' self.parser.description = description or ''
if arguments: if arguments:
self.arguments = arguments self.arguments = arguments
...@@ -613,7 +616,7 @@ class ArgumentParseManager(object): ...@@ -613,7 +616,7 @@ class ArgumentParseManager(object):
self.update_parser() self.update_parser()
def _parse_required_arguments(self, required, parsed_args): def _parse_required_arguments(self, required, parsed_args):
if not required: if not (self.check_required and required):
return True return True
if isinstance(required, tuple): if isinstance(required, tuple):
for item in required: for item in required:
...@@ -175,10 +175,9 @@ class Shell(Cmd): ...@@ -175,10 +175,9 @@ class Shell(Cmd):
tmp_args.pop('verbose', None) tmp_args.pop('verbose', None)
tmp_args.pop('silent', None) tmp_args.pop('silent', None)
tmp_args.pop('config', 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( 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 return help_parser.print_help
def _register_command(self, cmd_path): def _register_command(self, cmd_path):
...@@ -252,7 +252,7 @@ class OutputFormatArgument(ValueArgument): ...@@ -252,7 +252,7 @@ class OutputFormatArgument(ValueArgument):
@property @property
def value(self): def value(self):
return self._value return getattr(self, '_value', None)
@value.setter @value.setter
def value(self, newvalue): 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