Skip to content

handlers

create_dict_handler(pretty, as_yaml)

Create a json or yaml handler.

Parameters:

Name Type Description Default
pretty bool

If true, t highlights the output.

required
as_yaml bool

If true, it formats using yaml.

required

Returns:

Type Description
Callable[[Any], None]

A function that uses the arguments

Source code in m/cli/handlers.py
def create_dict_handler(pretty: bool, as_yaml: bool) -> Callable[[Any], None]:
    """Create a json or yaml handler.

    Args:
        pretty: If true, t highlights the output.
        as_yaml: If true, it formats using yaml.

    Returns:
        A function that uses the arguments
    """
    return (
        create_yaml_handler(pretty)
        if as_yaml
        else create_json_handler(pretty)
    )

create_issue_handler(use_warning)

Generate a function to log an issue.

Parameters:

Name Type Description Default
use_warning bool

Uses a warning log instead of an error.

required

Returns:

Type Description
Callable[[Issue], None]

A function that uses the arguments provided.

Source code in m/cli/handlers.py
def create_issue_handler(use_warning: bool) -> Callable[[Issue], None]:
    """Generate a function to log an issue.

    Args:
        use_warning: Uses a warning log instead of an error.

    Returns:
        A function that uses the arguments provided.
    """
    return partial(_issue_handler, use_warning)

create_json_handler(pretty)

Generate a function to display a value to stdout as json.

Parameters:

Name Type Description Default
pretty bool

If true, it formats with indentation of 2 spaces.

required

Returns:

Type Description
Callable[[Any], None]

A function that uses the arguments provided.

Source code in m/cli/handlers.py
def create_json_handler(pretty: bool) -> Callable[[Any], None]:
    """Generate a function to display a value to stdout as json.

    Args:
        pretty: If true, it formats with indentation of 2 spaces.

    Returns:
        A function that uses the arguments provided.
    """
    return partial(_json_handler, pretty)

create_yaml_handler(pretty)

Generate a function to display a value to stdout as yaml.

Parameters:

Name Type Description Default
pretty bool

If true, it highlights the output.

required

Returns:

Type Description
Callable[[Any], None]

A function that uses the arguments provided.

Source code in m/cli/handlers.py
def create_yaml_handler(pretty: bool) -> Callable[[Any], None]:
    """Generate a function to display a value to stdout as yaml.

    Args:
        pretty: If true, it highlights the output.

    Returns:
        A function that uses the arguments provided.
    """
    return partial(_yaml_handler, pretty)