cli: Add possibility to hide commands in --help

This commit is contained in:
Alexandre Aubin 2022-02-08 14:45:02 +01:00
parent 7e2da7a897
commit cb9ecb468d
2 changed files with 5 additions and 0 deletions

View file

@ -260,11 +260,14 @@ class _ExtendedSubParsersAction(argparse._SubParsersAction):
self._deprecated_command_map = {}
def add_parser(self, name, type_=None, **kwargs):
hide_in_help = kwargs.pop("hide_in_help", False)
deprecated = kwargs.pop("deprecated", False)
deprecated_alias = kwargs.pop("deprecated_alias", [])
if deprecated:
self._deprecated_command_map[name] = None
if deprecated or hide_in_help:
if "help" in kwargs:
del kwargs["help"]

View file

@ -364,6 +364,7 @@ class ActionsMapParser(BaseActionsMapParser):
action_help=None,
deprecated=False,
deprecated_alias=[],
hide_in_help=False,
**kwargs,
):
"""Add a parser for an action
@ -384,6 +385,7 @@ class ActionsMapParser(BaseActionsMapParser):
description=action_help,
deprecated=deprecated,
deprecated_alias=deprecated_alias,
hide_in_help=hide_in_help,
)
def add_global_arguments(self, arguments):