From 7332d133a772e826a753d6c2df823e405ca4fabf Mon Sep 17 00:00:00 2001 From: masterlyj <167326996+masterlyj@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:49:08 +0800 Subject: [PATCH] feat(cli): add --config option to channels login and status commands Allows users to specify custom config file paths when managing channels. Usage: nanobot channels login weixin --config .nanobot-feishu/config.json nanobot channels status -c .nanobot-qq/config.json - Added optional --config/-c parameter to both commands - Defaults to ~/.nanobot/config.json when not specified - Maintains backward compatibility --- nanobot/cli/commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 49521aa16..b1a15ebfd 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -1023,12 +1023,14 @@ app.add_typer(channels_app, name="channels") @channels_app.command("status") -def channels_status(): +def channels_status( + config_path: str | None = typer.Option(None, "--config", "-c", help="Path to config file"), +): """Show channel status.""" from nanobot.channels.registry import discover_all from nanobot.config.loader import load_config - config = load_config() + config = load_config(Path(config_path) if config_path else None) table = Table(title="Channel Status") table.add_column("Channel", style="cyan") @@ -1115,12 +1117,13 @@ def _get_bridge_dir() -> Path: def channels_login( channel_name: str = typer.Argument(..., help="Channel name (e.g. weixin, whatsapp)"), force: bool = typer.Option(False, "--force", "-f", help="Force re-authentication even if already logged in"), + config_path: str | None = typer.Option(None, "--config", "-c", help="Path to config file"), ): """Authenticate with a channel via QR code or other interactive login.""" from nanobot.channels.registry import discover_all from nanobot.config.loader import load_config - config = load_config() + config = load_config(Path(config_path) if config_path else None) channel_cfg = getattr(config.channels, channel_name, None) or {} # Validate channel exists