fix(cli): honor custom config path in channel commands

This commit is contained in:
Xubin Ren
2026-04-02 18:37:46 +08:00
committed by Xubin Ren
parent 11ba733ab6
commit 3558fe4933
2 changed files with 63 additions and 4 deletions
+12 -4
View File
@@ -1028,9 +1028,13 @@ def channels_status(
):
"""Show channel status."""
from nanobot.channels.registry import discover_all
from nanobot.config.loader import load_config
from nanobot.config.loader import load_config, set_config_path
config = load_config(Path(config_path) if config_path else None)
resolved_config_path = Path(config_path).expanduser().resolve() if config_path else None
if resolved_config_path is not None:
set_config_path(resolved_config_path)
config = load_config(resolved_config_path)
table = Table(title="Channel Status")
table.add_column("Channel", style="cyan")
@@ -1121,9 +1125,13 @@ def channels_login(
):
"""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
from nanobot.config.loader import load_config, set_config_path
config = load_config(Path(config_path) if config_path else None)
resolved_config_path = Path(config_path).expanduser().resolve() if config_path else None
if resolved_config_path is not None:
set_config_path(resolved_config_path)
config = load_config(resolved_config_path)
channel_cfg = getattr(config.channels, channel_name, None) or {}
# Validate channel exists