Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
9b3c8fd9
Commit
9b3c8fd9
authored
Nov 29, 2013
by
Stavros Sachtouris
Browse files
Fix required args parsing in kamaki shell mode
parent
b8b1e2f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/argument/__init__.py
View file @
9b3c8fd9
...
...
@@ -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
,
check_required
=
True
):
"""
: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):
self
.
update_parser
()
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
:
...
...
kamaki/cli/command_shell.py
View file @
9b3c8fd9
...
...
@@ -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
):
...
...
kamaki/cli/commands/__init__.py
View file @
9b3c8fd9
...
...
@@ -252,7 +252,7 @@ class OutputFormatArgument(ValueArgument):
@
property
def
value
(
self
):
return
self
.
_value
return
getattr
(
self
,
'
_value
'
,
None
)
@
value
.
setter
def
value
(
self
,
newvalue
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment