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>
This commit is contained in:
lishengzxc
2026-06-14 23:44:17 +08:00
parent 2182a2239f
commit 6c716e5120
2 changed files with 18 additions and 5 deletions
+13 -1
View File
@@ -85,6 +85,10 @@ export default defineCommand({
usage: "bl auth login --api-key <key> | bl auth login --console",
options: [
{ flag: "--api-key <key>", description: "DashScope API key to store" },
{
flag: "--base-url <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<string, unknown>;
existing.base_url = baseUrl;
await writeConfigFile(existing);
}
printQuickStart();
} else {
emitBare("Would validate and save API key.");
+5 -4
View File
@@ -25,10 +25,11 @@ Index: [index.md](index.md)
#### Options
| Flag | Type | Required | Description |
| ----------------- | ------- | -------- | ------------------------------------------------------------------------ |
| `--api-key <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 <key>` | string | no | DashScope API key to store |
| `--base-url <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