bailian-cli-runtime 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -106,7 +106,7 @@ export declare class CommandRegistry {
106
106
  * dispatch switches on it. No scattered `argv.includes(...)` + `process.exit`.
107
107
  * - version: print the version and stop.
108
108
  * - help: print help for `path` (root [] / a group / an explicit --help). Terminal.
109
- * - run: execute `command`; `rest` is the flag region for parseFlags.
109
+ * - run: execute `command` with the already parsed and validated flags.
110
110
  * - usageError: the path doesn't exist (or has unexpected args); render and stop.
111
111
  */
112
112
  type Resolution = {
@@ -114,21 +114,23 @@ type Resolution = {
114
114
  } | {
115
115
  kind: "help";
116
116
  path: string[];
117
+ parsedFlags: Record<string, unknown>;
117
118
  } | {
118
119
  kind: "run";
119
120
  path: string[];
120
121
  command: AnyCommand;
121
122
  rest: string[];
123
+ parsedFlags: Record<string, unknown>;
122
124
  } | {
123
125
  kind: "usageError";
124
126
  error: UsageError;
125
127
  };
126
128
  /**
127
- * Classify argv into a {@link Resolution}. Pure over (argv, registry): one
128
- * `parsePath` scan for the command path + flag region, one `registry.locate`
129
- * for the routing decision. Never throws. Trivially unit-testable.
129
+ * Classify argv into a {@link Resolution}. Pure over (argv, registry).
130
+ * Match the command, then parse and validate all flags once. Help/version skip
131
+ * required enforcement. Dispatch reuses the parsed flags instead of parsing again.
130
132
  */
131
- export declare function resolve(argv: string[], registry: CommandRegistry): Resolution;
133
+ export declare function resolve(argv: string[], registry: CommandRegistry, localize?: Translator["localize"]): Resolution;
132
134
  //#endregion
133
135
  //#region src/middleware.d.ts
134
136
  /**
@@ -168,26 +170,31 @@ export declare function compose(stack: Middleware[]): (ctx: RunContext) => Promi
168
170
  //#endregion
169
171
  //#region src/args.d.ts
170
172
  interface ParsePathResult {
171
- /** Command path: the leading run of bare tokens, e.g. ["speech", "recognize"]. */
173
+ /** Command path: consecutive bare tokens after any leading global flags. */
172
174
  path: string[];
173
- /** Everything from the first flag onward — handed to parseFlags later. */
175
+ /**
176
+ * Flag region handed to parseFlags later.
177
+ * Includes peeled leading GLOBAL_FLAGS plus everything after the command path.
178
+ */
174
179
  rest: string[];
175
180
  hasHelpFlag: boolean;
176
181
  hasVersionFlag: boolean;
177
182
  }
178
183
  /**
179
- * First pass — routing only. The command path is the leading run of bare
180
- * (non-`-`) tokens; the first flag ends it ("command path first, then flags",
181
- * oclif-style). There are no positionals, so nothing bare can legitimately
182
- * follow a flag — and no flags precede the path, so this needs no schema.
184
+ * First-pass routing parse.
185
+ * - Known GLOBAL_FLAGS may appear before the command path (git/docker style).
186
+ * - Bare tokens form the command path; everything after the path goes into rest.
187
+ * - Unknown flags before the path throw UsageError (no silent root-help fallback).
183
188
  */
184
- export declare function parsePath(argv: string[]): ParsePathResult;
189
+ export declare function parsePath(argv: string[], localize?: Translator["localize"]): ParsePathResult;
185
190
  /**
186
191
  * Second pass — parse the flag region into typed values, driven entirely by the
187
192
  * keyed FlagsDef (key = camelCase flag name). Pure: returns typed flags or
188
193
  * throws UsageError — never prints/exits. The error boundary decides rendering.
189
194
  */
190
- export declare function parseFlags<F extends FlagsDef>(rest: string[], defs: F): ParsedFlags<F>;
195
+ export declare function parseFlags<F extends FlagsDef>(rest: string[], defs: F, localize?: Translator["localize"], options?: {
196
+ enforceRequired?: boolean;
197
+ }): ParsedFlags<F>;
191
198
  //#endregion
192
199
  //#region src/proxy.d.ts
193
200
  export declare function setupProxyFromEnv(): void;