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

Public Member Functions

def print_subparsers (self, parser, prefix="")
 
def __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 968 of file cli_main.py.

Member Function Documentation

◆ __call__()

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

Definition at line 988 of file cli_main.py.

988 def __call__(self, parser, namespace, values, option_string=None):
989 """Show full help message"""
990 # run in pager because amount of options will be looong
991 with Pager(f"{parser.prog} {option_string}"):
992 parser.print_help()
993 self.print_subparsers(parser)
994 parser.exit()
995
996

◆ print_subparsers()

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

Definition at line 971 of file cli_main.py.

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

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