Skip to content

commands

drunc.controller.interface.commands

Functions:

echo(obj, text, server, logger, target, execute_along_path, execute_on_all_subsequent_children_in_path)

Log a message locally or send it to the controller server.

Source code in drunc/controller/interface/commands.py
@click.command("echo")
@click.argument("text", required=True)
@click.option("--target", type=str, help="The target to address", default="")
@click.option(
    "--server/--local",
    default=False,
    help="Send the message to the server via RPC (default: log locally only).",
)
@click.option(
    "--execute-along-path/--dont-execute-along-path",
    is_flag=True,
    show_default=True,
    help="Execute the command along the path",
    default=False,
)
@click.option(
    "--logger",
    type=click.Choice(["echo", "main"]),
    default="echo",
    callback=lambda context, parameter, value: LoggerTarget.Value(value.upper()),
    help="Which server-side logger to target when --server is used.",
)
@click.option(
    "--execute-on-all-subsequent-children-in-path/--dont-execute-on-all-subsequent-children-in-path",
    is_flag=True,
    show_default=True,
    help="Execute the command on all subsequent children in the path",
    default=False,
)
@click.pass_obj
def echo(
    obj: ControllerContext,
    text: str,
    server: bool,
    logger: int,
    target: str,
    execute_along_path: bool,
    execute_on_all_subsequent_children_in_path: bool,
) -> None:
    """Log a message locally or send it to the controller server."""
    if not server:
        # Local-only path, no RPC — mirrors the old bare `echo` command.
        (log_echo if logger == LoggerTarget.ECHO else log).info(text)
        return

    obj.get_driver("controller").send_log(
        text=text,
        target=target,
        execute_along_path=execute_along_path,
        execute_on_all_subsequent_children_in_path=execute_on_all_subsequent_children_in_path,
        logger=logger,
    )

status(obj, target, execute_along_path, execute_on_all_subsequent_children_in_path, extended, width, fit)

Show the status of the controller and its managed components.

Parameters:

Name Type Description Default
obj ControllerContext

The controller context.

required
target str

The target to address.

required
execute_along_path bool

Whether to execute the command along the path.

required
execute_on_all_subsequent_children_in_path bool

Whether to execute the command on all subsequent children in the path.

required
extended bool

Whether to show additional columns, including the IP address of each endpoint.

required
width int | None

The table width. Default is automatically calculated.

required
fit bool

Whether to restrict the table to the available terminal width.

required

Returns:

Type Description
None

None

Source code in drunc/controller/interface/commands.py
@click.command("status")
@click.option("--target", type=str, help="The target to address", default="")
@click.option(
    "--execute-along-path/--dont-execute-along-path",
    is_flag=True,
    show_default=True,
    help="Execute the command along the path",
    default=True,
)
@click.option(
    "--execute-on-all-subsequent-children-in-path/--dont-execute-on-all-subsequent-children-in-path",
    is_flag=True,
    show_default=True,
    help="Execute the command on all subsequent children in the path",
    default=True,
)
@click.option(
    "--extended",
    is_flag=True,
    default=False,
    help="Show additional columns, including the IP address of each endpoint.",
)
@click.option(
    "-w",
    "--width",
    type=int,
    default=None,
    help="Table width. Default is automatically calculated",
)
@click.option(
    "--fit",
    is_flag=True,
    default=False,
    help="Restrict the table to the available terminal width.",
)
@click.pass_obj
def status(
    obj: ControllerContext,
    target: str,
    execute_along_path: bool,
    execute_on_all_subsequent_children_in_path: bool,
    extended: bool,
    width: int | None,
    fit: bool,
) -> None:
    """
    Show the status of the controller and its managed components.

    Args:
        obj (ControllerContext): The controller context.
        target (str): The target to address.
        execute_along_path (bool): Whether to execute the command along the path.
        execute_on_all_subsequent_children_in_path (bool): Whether to execute the command on all subsequent children in the path.
        extended (bool): Whether to show additional columns, including the IP address of each endpoint.
        width (int | None): The table width. Default is automatically calculated.
        fit (bool): Whether to restrict the table to the available terminal width.

    Returns:
        None

    Raises:
        None
    """
    log_msg = (
        f"Getting status for target '{target}'..."
        if target
        else "Getting status for all targets..."
    )
    obj.log.info(log_msg)
    table = render_status_table(
        obj,
        target=target,
        execute_along_path=execute_along_path,
        execute_on_all_subsequent_children_in_path=execute_on_all_subsequent_children_in_path,
        show_ip_address=extended,
        width=width,
    )
    table = format_table_width(obj, table, fit)
    obj.print(table, soft_wrap=not fit)
    obj.print_status_summary()