From 6c716e51204cbedca30ce9aab6ad2126fe4e03f5 Mon Sep 17 00:00:00 2001 From: lishengzxc <306009337@qq.com> Date: Sun, 14 Jun 2026 23:44:17 +0800 Subject: [PATCH] feat(auth): add --base-url flag to bl auth login When used with --api-key, validates the key against the specified base URL and persists it to config. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/auth/login.ts | 14 +++++++++++++- skills/bailian-cli/reference/auth.md | 9 +++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.ts index 540bd5e..71440f8 100644 --- a/packages/cli/src/commands/auth/login.ts +++ b/packages/cli/src/commands/auth/login.ts @@ -85,6 +85,10 @@ export default defineCommand({ usage: "bl auth login --api-key | bl auth login --console", options: [ { flag: "--api-key ", description: "DashScope API key to store" }, + { + flag: "--base-url ", + description: "DashScope API base URL (used with --api-key for validation)", + }, { flag: "--console", description: "Sign in via browser; opens the console login URL in your default browser", @@ -130,8 +134,16 @@ export default defineCommand({ process.exit(0); } + const baseUrl = (flags.baseUrl as string) || undefined; + const effectiveConfig = baseUrl ? { ...config, baseUrl } : config; + if (!config.dryRun) { - await validateKeyAndPersist(config, key); + await validateKeyAndPersist(effectiveConfig, key); + if (baseUrl) { + const existing = readConfigFile() as Record; + existing.base_url = baseUrl; + await writeConfigFile(existing); + } printQuickStart(); } else { emitBare("Would validate and save API key."); diff --git a/skills/bailian-cli/reference/auth.md b/skills/bailian-cli/reference/auth.md index 3790ae5..e51eb1a 100644 --- a/skills/bailian-cli/reference/auth.md +++ b/skills/bailian-cli/reference/auth.md @@ -25,10 +25,11 @@ Index: [index.md](index.md) #### Options -| Flag | Type | Required | Description | -| ----------------- | ------- | -------- | ------------------------------------------------------------------------ | -| `--api-key ` | string | no | DashScope API key to store | -| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser | +| Flag | Type | Required | Description | +| ------------------ | ------- | -------- | ------------------------------------------------------------------------ | +| `--api-key ` | string | no | DashScope API key to store | +| `--base-url ` | string | no | DashScope API base URL (used with --api-key for validation) | +| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser | #### Examples