diff --git a/moulinette/actionsmap.py b/moulinette/actionsmap.py index 9f8da1f5..5c468a42 100644 --- a/moulinette/actionsmap.py +++ b/moulinette/actionsmap.py @@ -605,7 +605,7 @@ class ActionsMap(object): if top_parser.has_global_parser(): # GLOBAL_SECTION = '_global' - _add_arguments(GLOBAL_SECTION, top_parser.get_global_parser(), + _add_arguments(GLOBAL_SECTION, top_parser.global_parser, _global['arguments']) # category_name is stuff like "user", "domain", "hooks"... diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 345624b1..3147dcf2 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -548,9 +548,6 @@ class ActionsMapParser(BaseActionsMapParser): return [name.replace('--', '@', 1)] return [name.replace('-', '@', 1)] - def get_global_parser(self, **kwargs): - raise AttributeError("global arguments are not managed") - def add_category_parser(self, name, **kwargs): return self diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index 6a85f7a5..33468f00 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -231,14 +231,15 @@ class ActionsMapParser(BaseActionsMapParser): self._parser = parser or ExtendedArgumentParser() self._subparsers = self._parser.add_subparsers(**subparser_kwargs) - self._global_parser = parent._global_parser if parent else None + self.global_parser = parent.global_parser if parent else None if top_parser: + self.global_parser = self._parser.add_argument_group("global arguments") + # Append each top parser action to the global group - glob = self.get_global_parser() for action in top_parser._actions: action.dest = SUPPRESS - glob._add_action(action) + self.global_parser._add_action(action) # Implement virtual properties @@ -255,12 +256,6 @@ class ActionsMapParser(BaseActionsMapParser): def has_global_parser(self): return True - def get_global_parser(self, **kwargs): - if not self._global_parser: - self._global_parser = self._parser.add_argument_group( - "global arguments") - return self._global_parser - def add_category_parser(self, name, category_help=None, **kwargs): """Add a parser for a category