Skip to content

channel_cmd

channel_cmd

jarvis channel -- channel management commands.

Functions

channel

channel() -> None

Manage messaging channels.

Source code in src/openjarvis/cli/channel_cmd.py
@click.group()
def channel() -> None:
    """Manage messaging channels."""

channel_list

channel_list(channel_type: Optional[str]) -> None

List available channels.

Source code in src/openjarvis/cli/channel_cmd.py
@channel.command("list")
@click.option(
    "--channel-type", default=None, help=_CHANNEL_TYPE_HELP,
)
def channel_list(
    channel_type: Optional[str],
) -> None:
    """List available channels."""
    console = Console()
    from openjarvis.core.config import load_config

    config = load_config()

    try:
        ch = _get_channel(channel_type, config)
    except click.ClickException as exc:
        console.print(f"[red]{exc.message}[/red]")
        return

    try:
        channels = ch.list_channels()
    except Exception as exc:
        console.print(f"[red]Failed to list channels: {exc}[/red]")
        return

    if not channels:
        console.print("[yellow]No channels available[/yellow]")
        return

    table = Table(title="Available Channels")
    table.add_column("Channel", style="cyan")
    for name in channels:
        table.add_row(name)
    console.print(table)

channel_send

channel_send(target: str, message: str, channel_type: Optional[str]) -> None

Send a message to a channel.

Source code in src/openjarvis/cli/channel_cmd.py
@channel.command("send")
@click.argument("target")
@click.argument("message")
@click.option(
    "--channel-type", default=None, help=_CHANNEL_TYPE_HELP,
)
def channel_send(
    target: str,
    message: str,
    channel_type: Optional[str],
) -> None:
    """Send a message to a channel."""
    console = Console()
    from openjarvis.core.config import load_config

    config = load_config()

    try:
        ch = _get_channel(channel_type, config)
    except click.ClickException as exc:
        console.print(f"[red]{exc.message}[/red]")
        return

    ok = ch.send(target, message)
    if ok:
        console.print(f"[green]Message sent to {target}[/green]")
    else:
        console.print(
            f"[red]Failed to send message to {target}[/red]",
        )

channel_status

channel_status(channel_type: Optional[str]) -> None

Show channel connection status.

Source code in src/openjarvis/cli/channel_cmd.py
@channel.command("status")
@click.option(
    "--channel-type", default=None, help=_CHANNEL_TYPE_HELP,
)
def channel_status(
    channel_type: Optional[str],
) -> None:
    """Show channel connection status."""
    console = Console()
    from openjarvis.core.config import load_config

    config = load_config()

    try:
        ch = _get_channel(channel_type, config)
    except click.ClickException as exc:
        console.print(f"[red]{exc.message}[/red]")
        return

    st = ch.status()
    color = {
        "connected": "green",
        "disconnected": "yellow",
        "connecting": "blue",
        "error": "red",
    }.get(st.value, "white")

    key = channel_type or config.channel.default_channel or "unknown"
    console.print(f"Channel: [cyan]{key}[/cyan]")
    console.print(f"Status: [{color}]{st.value}[/{color}]")