onyo.main module
- class onyo.main.OnyoArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]
Bases:
ArgumentParserRich-ified ArgumentParser.
See also
- class onyo.main.OnyoRawTextHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]
Bases:
RawTextHelpFormatterFix the sins of argparse’s formatting; convert RST to Rich markup.
See also
argparse.ArgumentParser.RawTextHelpFormatter
- onyo.main.build_parser(parser, args)[source]
Add options or arguments to an ArgumentParser.
- Parameters:
parser (
ArgumentParser) – Parser to add arguments to.args (
dict) – Dictionary of option/argument dictionaries containing key-values to pass to ArgumentParser.add_argument(). The key name of the option/argument dictionary is passed as the value todest.
- Return type:
See also
ArgumentParser.add_argumentExample
An example option/argument dictionary:
args = { 'debug': dict( args=('-d', '--debug'), required=False, default=False, action='store_true', help=r"Enable debug logging." ), } build_parser(parser, args)
- onyo.main.get_subcmd_index(arglist, start=1)[source]
Get the index of the Onyo subcommand in a list of arguments.
- Parameters:
- Return type:
Example
>>> subcmd_index = get_subcmd_index(sys.argv)
- onyo.main.rst_to_rich(text)[source]
Convert RST to Rich syntax.
Naively convert reStructuredText to Rich syntax, de-indent, and apply other cleanups to prepare text to print to the terminal.