Compare commits

...

2 commits

4 changed files with 17 additions and 9 deletions

View file

@ -1,3 +1,9 @@
## 0.7.0a4 (2025-11-21)
### Feat
- add 'add_help' option un TiramisuCmdLineParser
## 0.7.0a3 (2025-10-10) ## 0.7.0a3 (2025-10-10)
### Feat ### Feat

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "tiramisu_cmdline_parser" name = "tiramisu_cmdline_parser"
version = "0.7.0a3" version = "0.7.0a4"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "command-line parser using Tiramisu" description = "command-line parser using Tiramisu"

View file

@ -1 +1 @@
__version__ = "0.7.0a3" __version__ = "0.7.0a4"

View file

@ -332,6 +332,7 @@ class TiramisuCmdlineParser(ArgumentParser):
unrestraint: bool = False, unrestraint: bool = False,
add_extra_options: bool = True, add_extra_options: bool = True,
short_name_max_len: int = 1, short_name_max_len: int = 1,
add_help: bool = True,
_forhelp: bool = False, _forhelp: bool = False,
**kwargs, **kwargs,
): ):
@ -345,6 +346,7 @@ class TiramisuCmdlineParser(ArgumentParser):
self.add_extra_options = add_extra_options self.add_extra_options = add_extra_options
self.display_modified_value = display_modified_value self.display_modified_value = display_modified_value
self.short_name_max_len = short_name_max_len self.short_name_max_len = short_name_max_len
self.add_help = add_help
if TiramisuHelpFormatter not in formatter_class.__mro__: if TiramisuHelpFormatter not in formatter_class.__mro__:
formatter_class = type( formatter_class = type(
"TiramisuHelpFormatter", (TiramisuHelpFormatter, formatter_class), {} "TiramisuHelpFormatter", (TiramisuHelpFormatter, formatter_class), {}
@ -361,7 +363,7 @@ class TiramisuCmdlineParser(ArgumentParser):
else: else:
subconfig = subconfig.option(self.root) subconfig = subconfig.option(self.root)
self.namespace = TiramisuNamespace(self.config, self.root) self.namespace = TiramisuNamespace(self.config, self.root)
super().__init__(*args, **kwargs) super().__init__(*args, add_help=add_help, **kwargs)
self.register("action", "help", _TiramisuHelpAction) self.register("action", "help", _TiramisuHelpAction)
self._config_to_argparser( self._config_to_argparser(
_forhelp, _forhelp,
@ -419,16 +421,16 @@ class TiramisuCmdlineParser(ArgumentParser):
add_extra_options=self.add_extra_options, add_extra_options=self.add_extra_options,
short_name_max_len=self.short_name_max_len, short_name_max_len=self.short_name_max_len,
fullpath=self.fullpath, fullpath=self.fullpath,
add_help=self.add_help,
) )
namespace_, args_ = new_parser._parse_known_args( namespace_, args_ = new_parser._parse_known_args(
args_, new_parser.namespace, *others args_, new_parser.namespace, *others
) )
else: elif self._registries["action"]["help"].needs:
if self._registries["action"]["help"].needs: # display help only when all variables assignemnt are done
# display help only when all variables assignemnt are done self._registries["action"]["help"].needs = False
self._registries["action"]["help"].needs = False helper = self._registries["action"]["help"](None)
helper = self._registries["action"]["help"](None) helper.display(self)
helper.display(self)
return namespace_, args_ return namespace_, args_
def add_argument(self, *args, **kwargs): def add_argument(self, *args, **kwargs):