problem with boolean option
This commit is contained in:
parent
e2c4e3381a
commit
504d5d71a4
2 changed files with 13 additions and 11 deletions
|
@ -250,7 +250,7 @@ def test_readme_help_modif_short_remove(json):
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-nv, --no-verbosity
|
-nv, --no-verbosity increase output verbosity
|
||||||
--str STR string option
|
--str STR string option
|
||||||
"""
|
"""
|
||||||
parser = TiramisuCmdlineParser(get_config(json), 'prog.py', display_modified_value=False)
|
parser = TiramisuCmdlineParser(get_config(json), 'prog.py', display_modified_value=False)
|
||||||
|
@ -265,7 +265,7 @@ optional arguments:
|
||||||
assert f.getvalue() == output
|
assert f.getvalue() == output
|
||||||
|
|
||||||
|
|
||||||
def test_readme_help_modif_short_no(json):
|
def test_readme_help_modif_short_no1(json):
|
||||||
output = """usage: prog.py "str" -v [-h] [-v] [-nv] --str STR {str,list,int,none}
|
output = """usage: prog.py "str" -v [-h] [-v] [-nv] --str STR {str,list,int,none}
|
||||||
|
|
||||||
positional arguments:
|
positional arguments:
|
||||||
|
@ -290,13 +290,12 @@ optional arguments:
|
||||||
|
|
||||||
|
|
||||||
def test_readme_help_modif_short_no_remove(json):
|
def test_readme_help_modif_short_no_remove(json):
|
||||||
# FIXME -v -nv ?? c'est -nv qui est set
|
output = """usage: prog.py "str" -v [-h] [-v] --str STR
|
||||||
output = """usage: prog.py "str" -v [-h] [-nv] --str STR
|
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-nv, --no-verbosity
|
-v, --verbosity increase output verbosity
|
||||||
--str STR string option
|
--str STR string option
|
||||||
"""
|
"""
|
||||||
parser = TiramisuCmdlineParser(get_config(json), 'prog.py', display_modified_value=False)
|
parser = TiramisuCmdlineParser(get_config(json), 'prog.py', display_modified_value=False)
|
||||||
f = StringIO()
|
f = StringIO()
|
||||||
|
|
|
@ -147,13 +147,15 @@ class _BuildKwargs:
|
||||||
cmdlineparser: 'TiramisuCmdlineParser',
|
cmdlineparser: 'TiramisuCmdlineParser',
|
||||||
properties: List[str],
|
properties: List[str],
|
||||||
force_no: bool,
|
force_no: bool,
|
||||||
force_del: bool) -> None:
|
force_del: bool,
|
||||||
|
display_modified_value: bool,
|
||||||
|
not_display: bool) -> None:
|
||||||
self.kwargs = {}
|
self.kwargs = {}
|
||||||
self.cmdlineparser = cmdlineparser
|
self.cmdlineparser = cmdlineparser
|
||||||
self.properties = properties
|
self.properties = properties
|
||||||
self.force_no = force_no
|
self.force_no = force_no
|
||||||
self.force_del = force_del
|
self.force_del = force_del
|
||||||
if not self.force_no and not self.force_del:
|
if (not self.force_no or (not_display and not display_modified_value)) and not self.force_del:
|
||||||
description = option.doc()
|
description = option.doc()
|
||||||
if not description:
|
if not description:
|
||||||
description = description.replace('%', '%%')
|
description = description.replace('%', '%%')
|
||||||
|
@ -404,8 +406,9 @@ class TiramisuCmdlineParser(ArgumentParser):
|
||||||
properties = obj.option.properties()
|
properties = obj.option.properties()
|
||||||
else:
|
else:
|
||||||
properties = obj.property.get()
|
properties = obj.property.get()
|
||||||
kwargs = _BuildKwargs(name, option, self, properties, force_no, force_del)
|
not_display = not option.isfollower() and not obj.owner.isdefault() and value is not None
|
||||||
if not option.isfollower() and _forhelp and not obj.owner.isdefault() and value is not None and not force_no:
|
kwargs = _BuildKwargs(name, option, self, properties, force_no, force_del, self.display_modified_value, not_display)
|
||||||
|
if _forhelp and not_display and ((value is not False and not force_no) or (value is False and force_no)):
|
||||||
options_is_not_default[option.name()] = {'properties': properties,
|
options_is_not_default[option.name()] = {'properties': properties,
|
||||||
'type': option.type(),
|
'type': option.type(),
|
||||||
'name': name,
|
'name': name,
|
||||||
|
|
Loading…
Reference in a new issue