Skip to content

cli_argument

drunc.process_manager.interface.cli_argument

Functions:

add_query_options(at_least_one, all_processes_by_default=False)

Decorator to add query options to a click command, including session selection.

Parameters:

Name Type Description Default
at_least_one bool

If True, at least one query option must be provided.

required
all_processes_by_default bool

If True, all processes will be selected by default if no query options are provided.

False

Returns:

Name Type Description
function Callable[[FC], FC]

A decorator function that adds query options to a click command.

Source code in drunc/process_manager/interface/cli_argument.py
def add_query_options(
    at_least_one: bool, all_processes_by_default: bool = False
) -> Callable[[FC], FC]:
    """
    Decorator to add query options to a click command, including session selection.

    Args:
        at_least_one (bool): If True, at least one query option must be provided.
        all_processes_by_default (bool): If True, all processes will be selected by
            default if no query options are provided.

    Returns:
        function: A decorator function that adds query options to a click command.
    """

    def wrapper(f0: FC) -> FC:
        f1 = click.option(
            "-s",
            "--session",
            type=str,
            default=None,
            help="Select the processes on a particular session",
        )(f0)
        return add_query_options_no_session(at_least_one, all_processes_by_default)(f1)

    return wrapper

add_query_options_no_session(at_least_one, all_processes_by_default=False)

Decorator to add query options to a click command.

Parameters:

Name Type Description Default
at_least_one bool

If True, at least one query option must be provided.

required
all_processes_by_default bool

If True, all processes will be selected by default if no query options are provided.

False

Returns:

Name Type Description
function Callable[[FC], FC]

A decorator function that adds query options to a click command.

Source code in drunc/process_manager/interface/cli_argument.py
def add_query_options_no_session(
    at_least_one: bool, all_processes_by_default: bool = False
) -> Callable[[FC], FC]:
    """
    Decorator to add query options to a click command.

    Args:
        at_least_one (bool): If True, at least one query option must be provided.
        all_processes_by_default (bool): If True, all processes will be selected by
            default if no query options are provided.

    Returns:
        function: A decorator function that adds query options to a click command.
    """

    def wrapper(f1: FC) -> FC:
        f2 = click.option(
            "-n",
            "--name",
            type=str,
            default=None,
            multiple=True,
            help="Select the process of a particular names",
        )(f1)
        f3 = click.option(
            "-u",
            "--user",
            type=str,
            default=None,
            help="Select the process of a particular user",
        )(f2)
        f4 = click.option(
            "--uuid",
            type=str,
            default=None,
            multiple=True,
            help="Select the process of a particular UUIDs",
        )(f3)
        return generate_process_query(f4, at_least_one, all_processes_by_default)

    return wrapper

validate_conf_string(ctx, param, boot_configuration)

Validate the boot configuration string.

Parameters:

Name Type Description Default
ctx Context

The Click context.

required
param Parameter

The Click parameter.

required
boot_configuration str

The boot configuration string to validate.

required

Returns:

Name Type Description
str str

The validated boot configuration string.

Source code in drunc/process_manager/interface/cli_argument.py
def validate_conf_string(
    ctx: Context, param: Parameter, boot_configuration: str
) -> str:
    """
    Validate the boot configuration string.

    Args:
        ctx (Context): The Click context.
        param (Parameter): The Click parameter.
        boot_configuration (str): The boot configuration string to validate.

    Returns:
        str: The validated boot configuration string.
    """
    return boot_configuration