Skip to content

synth_argparse

Class info

🛈 DocStrings

Module for generating ArgumentParser CLI implementations from CommandInfo objects.

create_parser

create_parser(cmd_info: CommandInfo) -> ArgumentParser

Create an ArgumentParser from a CommandInfo object.

Parameters:

Name Type Description Default
cmd_info CommandInfo

The CommandInfo object to convert

required

Returns:

Type Description
ArgumentParser

An ArgumentParser with all commands and (nested) subcommands

Source code in src/clinspector/synthesis/synth_argparse.py
def create_parser(cmd_info: CommandInfo) -> argparse.ArgumentParser:
    """Create an ArgumentParser from a CommandInfo object.

    Args:
        cmd_info: The CommandInfo object to convert

    Returns:
        An ArgumentParser with all commands and (nested) subcommands
    """
    parser = argparse.ArgumentParser(
        prog=cmd_info.name,
        description=cmd_info.description,
        epilog=cmd_info.epilog,
    )
    _populate(parser, cmd_info)
    return parser