diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts index 798abe0..1cf512c 100644 --- a/packages/cli/src/main.ts +++ b/packages/cli/src/main.ts @@ -3,11 +3,9 @@ import { registry } from "./registry.ts"; import { GLOBAL_OPTIONS, loadConfig, - readConfigFile, resolveCredential, trackCommandExecution, flushTelemetry, - type Region, } from "bailian-cli-core"; import { ensureApiKey } from "./utils/ensure-key.ts"; import { handleError } from "./error-handler.ts"; @@ -22,13 +20,7 @@ import { } from "./utils/command-help.ts"; registerCommandHelpPrinter((commandPath, out) => { - const a = process.argv.slice(2); - const ri = a.indexOf("--region"); - const region = ((ri >= 0 && a[ri + 1]) || - process.env.DASHSCOPE_REGION || - readConfigFile().region || - "cn") as Region; - registry.printHelp(commandPath, out, region); + registry.printHelp(commandPath, out); }); // 优雅处理 Ctrl+C @@ -84,12 +76,7 @@ async function main() { const commandPath = scanCommandPath(argv, GLOBAL_OPTIONS); if (argv.includes("--help") || argv.includes("-h")) { - const ri = argv.indexOf("--region"); - const region = ((ri >= 0 && argv[ri + 1]) || - process.env.DASHSCOPE_REGION || - readConfigFile().region || - "cn") as Region; - registry.printHelp(commandPath, process.stderr, region); + registry.printHelp(commandPath, process.stderr); process.exit(0); } @@ -115,12 +102,7 @@ async function main() { // 组路径(例如 `bl speech` 未接子命令):展示帮助后干净退出 if (registry.isGroupPath(commandPath)) { - const ri = argv.indexOf("--region"); - const region = ((ri >= 0 && argv[ri + 1]) || - process.env.DASHSCOPE_REGION || - readConfigFile().region || - "cn") as Region; - registry.printHelp(commandPath, process.stderr, region); + registry.printHelp(commandPath, process.stderr); process.exit(0); } diff --git a/packages/cli/src/registry.ts b/packages/cli/src/registry.ts index 3318c5a..70ed9f8 100644 --- a/packages/cli/src/registry.ts +++ b/packages/cli/src/registry.ts @@ -1,7 +1,7 @@ import type { Command } from "bailian-cli-core"; import { BailianError } from "bailian-cli-core"; import { ExitCode } from "bailian-cli-core"; -import { GLOBAL_OPTIONS, type Region } from "bailian-cli-core"; +import { GLOBAL_OPTIONS } from "bailian-cli-core"; import { commands } from "./commands/catalog.ts"; export type { Command, OptionDef } from "bailian-cli-core"; @@ -133,11 +133,7 @@ class CommandRegistry { out.isTTY ? `\x1b[38;2;59;130;246m${s}\x1b[0m` : s; private dim = (s: string, out: NodeJS.WriteStream) => (out.isTTY ? `\x1b[2m${s}\x1b[0m` : s); - printHelp( - commandPath: string[], - out: NodeJS.WriteStream = process.stdout, - region: Region = "cn", - ): void { + printHelp(commandPath: string[], out: NodeJS.WriteStream = process.stdout): void { if (commandPath.length === 0) { this.printRootHelp(out); return; @@ -154,7 +150,7 @@ class CommandRegistry { } if (node.command) { - this.printCommandHelp(node.command, out, region); + this.printCommandHelp(node.command, out); return; } @@ -233,7 +229,7 @@ ${b("Getting Help:")} `); } - private printCommandHelp(cmd: Command, out: NodeJS.WriteStream, region: Region = "cn"): void { + private printCommandHelp(cmd: Command, out: NodeJS.WriteStream): void { const b = (s: string) => this.bold(s, out); const a = (s: string) => this.accent(s, out); const d = (s: string) => this.dim(s, out);