Skip to content

Commit 6c716e5

Browse files
lishengzxcclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 2182a22 commit 6c716e5

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

packages/cli/src/commands/auth/login.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export default defineCommand({
8585
usage: "bl auth login --api-key <key> | bl auth login --console",
8686
options: [
8787
{ flag: "--api-key <key>", description: "DashScope API key to store" },
88+
{
89+
flag: "--base-url <url>",
90+
description: "DashScope API base URL (used with --api-key for validation)",
91+
},
8892
{
8993
flag: "--console",
9094
description: "Sign in via browser; opens the console login URL in your default browser",
@@ -130,8 +134,16 @@ export default defineCommand({
130134
process.exit(0);
131135
}
132136

137+
const baseUrl = (flags.baseUrl as string) || undefined;
138+
const effectiveConfig = baseUrl ? { ...config, baseUrl } : config;
139+
133140
if (!config.dryRun) {
134-
await validateKeyAndPersist(config, key);
141+
await validateKeyAndPersist(effectiveConfig, key);
142+
if (baseUrl) {
143+
const existing = readConfigFile() as Record<string, unknown>;
144+
existing.base_url = baseUrl;
145+
await writeConfigFile(existing);
146+
}
135147
printQuickStart();
136148
} else {
137149
emitBare("Would validate and save API key.");

skills/bailian-cli/reference/auth.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ Index: [index.md](index.md)
2525

2626
#### Options
2727

28-
| Flag | Type | Required | Description |
29-
| ----------------- | ------- | -------- | ------------------------------------------------------------------------ |
30-
| `--api-key <key>` | string | no | DashScope API key to store |
31-
| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser |
28+
| Flag | Type | Required | Description |
29+
| ------------------ | ------- | -------- | ------------------------------------------------------------------------ |
30+
| `--api-key <key>` | string | no | DashScope API key to store |
31+
| `--base-url <url>` | string | no | DashScope API base URL (used with --api-key for validation) |
32+
| `--console` | boolean | no | Sign in via browser; opens the console login URL in your default browser |
3233

3334
#### Examples
3435

0 commit comments

Comments
 (0)