Belle II Software development
FullHelpAction Class Reference
Inheritance diagram for FullHelpAction:

Public Member Functions

 print_subparsers (self, parser, prefix="")
 
 __call__ (self, parser, namespace, values, option_string=None)
 

Detailed Description

Class to recursively show help for an ArgumentParser and all it's sub_parsers

Definition at line 974 of file cli_main.py.

Member Function Documentation

◆ __call__()

__call__ ( self,
parser,
namespace,
values,
option_string = None )
Show full help message

Definition at line 994 of file cli_main.py.

994 def __call__(self, parser, namespace, values, option_string=None):
995 """Show full help message"""
996 # run in pager because amount of options will be looong
997 with Pager(f"{parser.prog} {option_string}"):
998 parser.print_help()
999 self.print_subparsers(parser)
1000 parser.exit()
1001
1002

◆ print_subparsers()

print_subparsers ( self,
parser,
prefix = "" )
Print help message for given parser and call again for all sub parsers

Definition at line 977 of file cli_main.py.

977 def print_subparsers(self, parser, prefix=""):
978 """Print help message for given parser and call again for all sub parsers"""
979 # retrieve subparsers from parser
980 subparsers_actions = [
981 action for action in parser._actions
982 if isinstance(action, argparse._SubParsersAction)]
983 # there will probably only be one subparser_action,
984 # but better save than sorry
985 for subparsers_action in subparsers_actions:
986 # get all subparsers and print help
987 for choice, subparser in subparsers_action.choices.items():
988 print()
989 print(f"Command '{prefix}{choice}'")
990 print(subparser.format_help())
991
992 self.print_subparsers(subparser, prefix=f"{prefix}{choice} ")
993

The documentation for this class was generated from the following file: