Skip to content

remainder

handle_field(name, field)

Set the remainder arguments.

Parameters:

Name Type Description Default
name str

The name of the field.

required
field FieldInfo

A dictionary representation of the field.

required

Returns:

Type Description
FuncArgs

Function arguments for the parser add_argument method.

Source code in m/cli/engine/parsers/remainder.py
def handle_field(name: str, field: FieldInfo) -> FuncArgs:
    """Set the remainder arguments.

    Args:
        name: The name of the field.
        field: A dictionary representation of the field.

    Returns:
        Function arguments for the parser `add_argument` method.
    """
    args: AnyMap = {
        'help': argument_description(field.description or '', MISSING),
        'nargs': argparse.REMAINDER,
    }
    return FuncArgs(args=[name], kwargs=args)

should_handle(extras)

Handle the __remainder_args field.

Parameters:

Name Type Description Default
extras AnyMap

A dictionary with information for a cli argument.

required

Returns:

Type Description
bool

True if it should provide the remainder arguments.

Source code in m/cli/engine/parsers/remainder.py
def should_handle(extras: AnyMap) -> bool:
    """Handle the __remainder_args field.

    Args:
        extras: A dictionary with information for a cli argument.

    Returns:
        True if it should provide the remainder arguments.
    """
    return extras.get('__remainder_args') is True