mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
deab3b3841
- flags split into GLOBAL_FLAGS (all commands) plus MODEL_AUTH_FLAGS / CONSOLE_AUTH_FLAGS, parsed only for commands of the matching auth domain; cross-domain flags now fail with "Unknown flag" instead of being silently ignored - all shadow redeclarations removed; the registry guard now rejects any own flag named after a reserved (global or visible-domain) flag - --workspace-id joins the console domain (chain: flag > env > file); usage stats drops its private declaration and in-command priority - auth login declares its credential args as own command parameters (--api-key / --base-url / --console-site, original behavior intact); auth status no longer accepts credential-domain overrides (use env or config set instead) - command help and the generated reference both show Flags (own + auth domain) plus a full Global Flags section, replacing the footer hint - breaking: pipeline run --timeout renamed to --step-timeout (collided with the global request timeout)
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { expect, test } from "vite-plus/test";
|
|
import { defineCommand } from "bailian-cli-core";
|
|
import { CommandRegistry } from "../src/registry.ts";
|
|
|
|
// 同名守卫:命令自有 flag 不得与全局或其可见凭证域 flag 同名。
|
|
|
|
const noopRun = async () => {};
|
|
|
|
test("命令重声明全局 flag → registry 构造抛错", () => {
|
|
const cmd = defineCommand({
|
|
description: "test",
|
|
auth: "none",
|
|
flags: { output: { type: "string", valueHint: "<f>", description: "dup" } },
|
|
run: noopRun,
|
|
});
|
|
expect(() => new CommandRegistry({ "x y": cmd }, "bl")).toThrow(/redeclares reserved flag/);
|
|
});
|
|
|
|
test("命令重声明其可见域的凭证 flag → 抛错;不可见域的同名 → 放行", () => {
|
|
const consoleCmd = defineCommand({
|
|
description: "test",
|
|
auth: "console",
|
|
flags: { consoleRegion: { type: "string", valueHint: "<r>", description: "dup" } },
|
|
run: noopRun,
|
|
});
|
|
expect(() => new CommandRegistry({ "x y": consoleCmd }, "bl")).toThrow(/consoleRegion/);
|
|
|
|
const modelCmd = defineCommand({
|
|
description: "test",
|
|
auth: "apiKey",
|
|
flags: { consoleRegion: { type: "string", valueHint: "<r>", description: "own" } },
|
|
run: noopRun,
|
|
});
|
|
expect(() => new CommandRegistry({ "x y": modelCmd }, "bl")).not.toThrow();
|
|
});
|