@outfitter/cli 0.5.0 → 0.5.2
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/README.md +2 -2
- package/dist/actions.d.ts +18 -3
- package/dist/actions.js +19 -2
- package/dist/cli.d.ts +1 -1
- package/dist/colors/colors.d.ts +1 -1
- package/dist/colors/index.d.ts +2 -2
- package/dist/command.d.ts +1 -1
- package/dist/completion.d.ts +2 -2
- package/dist/flags.d.ts +24 -2
- package/dist/flags.js +10 -2
- package/dist/index.d.ts +4 -4
- package/dist/input.d.ts +1 -1
- package/dist/output.d.ts +2 -2
- package/dist/pagination.d.ts +1 -1
- package/dist/query.d.ts +3 -3
- package/dist/query.js +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/shared/@outfitter/{cli-g0sn0r0b.js → cli-0cjts94k.js} +4 -4
- package/dist/shared/@outfitter/{cli-md9347gn.d.ts → cli-98aa9104.d.ts} +144 -51
- package/dist/shared/@outfitter/{cli-b2zk8fb3.js → cli-pdb7znbq.js} +144 -1
- package/dist/shared/@outfitter/{cli-k0yvzn6d.d.ts → cli-xy3gs50c.d.ts} +1 -1
- package/dist/terminal/detection.d.ts +1 -1
- package/dist/terminal/index.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/verbs.d.ts +1 -1
- package/package.json +9 -8
- package/dist/shared/@outfitter/{cli-xppg982q.d.ts → cli-j2x88att.d.ts} +49 -49
- package/dist/shared/@outfitter/{cli-8aa1vhdn.d.ts → cli-rr1sq5s4.d.ts} +2 -2
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ if (flags.reset) {
|
|
|
363
363
|
|
|
364
364
|
## Conventions
|
|
365
365
|
|
|
366
|
-
Composable flag presets provide typed, reusable CLI flag definitions. See the [full conventions guide](../../docs/
|
|
366
|
+
Composable flag presets provide typed, reusable CLI flag definitions. See the [full conventions guide](../../docs/cli/conventions.md) for the complete catalog.
|
|
367
367
|
|
|
368
368
|
```typescript
|
|
369
369
|
import { composePresets, verbosePreset, cwdPreset, forcePreset } from "@outfitter/cli/flags";
|
|
@@ -486,7 +486,7 @@ import type { PaginationState, CursorOptions } from "@outfitter/cli/pagination";
|
|
|
486
486
|
|
|
487
487
|
## Upgrading
|
|
488
488
|
|
|
489
|
-
Run `outfitter
|
|
489
|
+
Run `outfitter upgrade --guide` for version-specific migration instructions, or check the [migration docs](https://github.com/outfitter-dev/outfitter/tree/main/plugins/outfitter/shared/migrations) for detailed upgrade steps.
|
|
490
490
|
|
|
491
491
|
## License
|
|
492
492
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SchemaCommandOptions } from "./shared/@outfitter/cli-n1k0d23k";
|
|
2
|
-
import {
|
|
1
|
+
import { SchemaCommandOptions } from "./shared/@outfitter/cli-n1k0d23k.js";
|
|
2
|
+
import { FlagPreset } from "./shared/@outfitter/cli-98aa9104.js";
|
|
3
|
+
import { ActionCliInputContext, ActionCliOption, ActionRegistry, ActionSurface, AnyActionSpec, HandlerContext } from "@outfitter/contracts";
|
|
3
4
|
import { Command } from "commander";
|
|
4
5
|
interface BuildCliCommandsOptions {
|
|
5
6
|
readonly createContext?: (input: {
|
|
@@ -11,5 +12,19 @@ interface BuildCliCommandsOptions {
|
|
|
11
12
|
readonly schema?: boolean | SchemaCommandOptions;
|
|
12
13
|
}
|
|
13
14
|
type ActionSource = ActionRegistry | readonly AnyActionSpec[];
|
|
15
|
+
type ResolvedType<T> = T extends FlagPreset<infer R> ? R : never;
|
|
16
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
17
|
+
type MergedPresetResult<TPresets extends readonly FlagPreset<Record<string, unknown>>[]> = UnionToIntersection<ResolvedType<TPresets[number]>> extends Record<string, unknown> ? UnionToIntersection<ResolvedType<TPresets[number]>> : Record<string, unknown>;
|
|
18
|
+
interface ActionCliPresetAdapter<TResolved extends Record<string, unknown>> {
|
|
19
|
+
readonly options: readonly ActionCliOption[];
|
|
20
|
+
readonly resolve: (input: ActionCliInputContext | Record<string, unknown>) => TResolved;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Compose flag presets for action-spec CLI definitions.
|
|
24
|
+
*
|
|
25
|
+
* Returns an options array for `action.cli.options` and a typed `resolve()`
|
|
26
|
+
* that accepts either raw flags or full `ActionCliInputContext`.
|
|
27
|
+
*/
|
|
28
|
+
declare function actionCliPresets<TPresets extends readonly FlagPreset<Record<string, unknown>>[]>(...presets: TPresets): ActionCliPresetAdapter<MergedPresetResult<TPresets>>;
|
|
14
29
|
declare function buildCliCommands(source: ActionSource, options?: BuildCliCommandsOptions): Command[];
|
|
15
|
-
export { buildCliCommands, BuildCliCommandsOptions };
|
|
30
|
+
export { buildCliCommands, actionCliPresets, BuildCliCommandsOptions, ActionCliPresetAdapter };
|
package/dist/actions.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createSchemaCommand
|
|
4
|
-
} from "./shared/@outfitter/cli-
|
|
4
|
+
} from "./shared/@outfitter/cli-0cjts94k.js";
|
|
5
|
+
import {
|
|
6
|
+
composePresets
|
|
7
|
+
} from "./shared/@outfitter/cli-pdb7znbq.js";
|
|
5
8
|
|
|
6
9
|
// packages/cli/src/actions.ts
|
|
7
10
|
import {
|
|
@@ -11,6 +14,19 @@ import {
|
|
|
11
14
|
} from "@outfitter/contracts";
|
|
12
15
|
import { Command } from "commander";
|
|
13
16
|
var ARGUMENT_PREFIXES = ["<", "["];
|
|
17
|
+
function isInputContext(input) {
|
|
18
|
+
return "flags" in input && typeof input.flags === "object" && "args" in input && Array.isArray(input.args);
|
|
19
|
+
}
|
|
20
|
+
function actionCliPresets(...presets) {
|
|
21
|
+
const composed = composePresets(...presets);
|
|
22
|
+
return {
|
|
23
|
+
options: composed.options,
|
|
24
|
+
resolve: (input) => {
|
|
25
|
+
const flags = isInputContext(input) ? input.flags : input;
|
|
26
|
+
return composed.resolve(flags);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
14
30
|
function isArgumentToken(token) {
|
|
15
31
|
if (!token) {
|
|
16
32
|
return false;
|
|
@@ -180,5 +196,6 @@ function isActionRegistry(source) {
|
|
|
180
196
|
return "list" in source;
|
|
181
197
|
}
|
|
182
198
|
export {
|
|
183
|
-
buildCliCommands
|
|
199
|
+
buildCliCommands,
|
|
200
|
+
actionCliPresets
|
|
184
201
|
};
|
package/dist/cli.d.ts
CHANGED
package/dist/colors/colors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ANSI, ColorName, Theme, TokenOptions, Tokens, applyColor, createTheme, createTokens, resolveTokenColorEnabled } from "../shared/@outfitter/cli-
|
|
1
|
+
import { ANSI, ColorName, Theme, TokenOptions, Tokens, applyColor, createTheme, createTokens, resolveTokenColorEnabled } from "../shared/@outfitter/cli-j2x88att.js";
|
|
2
2
|
export { resolveTokenColorEnabled, createTokens, createTheme, applyColor, Tokens, TokenOptions, Theme, ColorName, ANSI };
|
package/dist/colors/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../shared/@outfitter/cli-qz47jk6d";
|
|
2
|
-
import { ANSI, ColorName, Theme, TokenOptions, Tokens, applyColor, createTheme, createTokens, resolveTokenColorEnabled } from "../shared/@outfitter/cli-
|
|
1
|
+
import "../shared/@outfitter/cli-qz47jk6d.js";
|
|
2
|
+
import { ANSI, ColorName, Theme, TokenOptions, Tokens, applyColor, createTheme, createTokens, resolveTokenColorEnabled } from "../shared/@outfitter/cli-j2x88att.js";
|
|
3
3
|
export { resolveTokenColorEnabled, createTokens, createTheme, applyColor, Tokens, TokenOptions, Theme, ColorName, ANSI };
|
package/dist/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CLI, CLIConfig, CommandAction, CommandBuilder, CommandConfig, CommandFlags, FlagPreset } from "./shared/@outfitter/cli-
|
|
1
|
+
import { CLI, CLIConfig, CommandAction, CommandBuilder, CommandConfig, CommandFlags, FlagPreset } from "./shared/@outfitter/cli-98aa9104.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a CLI instance with a portable return type from this module.
|
|
4
4
|
*/
|
package/dist/completion.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Command } from "commander";
|
|
|
3
3
|
* Configuration for the completion command.
|
|
4
4
|
*/
|
|
5
5
|
interface CompletionConfig {
|
|
6
|
-
/** Supported shells (default: bash, zsh, fish) */
|
|
7
|
-
readonly shells?: readonly ("bash" | "zsh" | "fish")[];
|
|
8
6
|
/** Program name for completion scripts (inferred from CLI name if not provided) */
|
|
9
7
|
readonly programName?: string;
|
|
8
|
+
/** Supported shells (default: bash, zsh, fish) */
|
|
9
|
+
readonly shells?: readonly ("bash" | "zsh" | "fish")[];
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Generate a completion script for the given shell.
|
package/dist/flags.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorFlags, ColorMode, ComposedPreset, ExecutionFlags, ExecutionPresetConfig, FlagPreset, FlagPresetConfig, InteractionFlags, PaginationFlags, PaginationPresetConfig, ProjectionFlags, StrictFlags, TimeWindowFlags, TimeWindowPresetConfig } from "./shared/@outfitter/cli-
|
|
1
|
+
import { BooleanFlagPresetConfig, ColorFlags, ColorMode, ComposedPreset, EnumFlagPresetConfig, ExecutionFlags, ExecutionPresetConfig, FlagPreset, FlagPresetConfig, InteractionFlags, NumberFlagPresetConfig, PaginationFlags, PaginationPresetConfig, ProjectionFlags, StrictFlags, StringListFlagPresetConfig, TimeWindowFlags, TimeWindowPresetConfig } from "./shared/@outfitter/cli-98aa9104.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a typed flag preset.
|
|
4
4
|
*
|
|
@@ -44,6 +44,28 @@ type MergedPresetResult<TPresets extends readonly FlagPreset<Record<string, unkn
|
|
|
44
44
|
*/
|
|
45
45
|
declare function composePresets<TPresets extends readonly FlagPreset<Record<string, unknown>>[]>(...presets: TPresets): ComposedPreset<MergedPresetResult<TPresets>>;
|
|
46
46
|
/**
|
|
47
|
+
* Generic boolean custom-flag builder.
|
|
48
|
+
*
|
|
49
|
+
* Supports normal sources and negated sources so `--no-foo` patterns can
|
|
50
|
+
* resolve consistently across Commander flag-shape differences.
|
|
51
|
+
*/
|
|
52
|
+
declare function booleanFlagPreset<TKey extends string>(config: BooleanFlagPresetConfig<TKey>): FlagPreset<{ [K in TKey] : boolean }>;
|
|
53
|
+
/**
|
|
54
|
+
* Generic enum custom-flag builder.
|
|
55
|
+
*/
|
|
56
|
+
declare function enumFlagPreset<
|
|
57
|
+
TKey extends string,
|
|
58
|
+
TValue extends string
|
|
59
|
+
>(config: EnumFlagPresetConfig<TKey, TValue>): FlagPreset<{ [K in TKey] : TValue }>;
|
|
60
|
+
/**
|
|
61
|
+
* Generic number custom-flag builder.
|
|
62
|
+
*/
|
|
63
|
+
declare function numberFlagPreset<TKey extends string>(config: NumberFlagPresetConfig<TKey>): FlagPreset<{ [K in TKey] : number }>;
|
|
64
|
+
/**
|
|
65
|
+
* Generic string-list custom-flag builder.
|
|
66
|
+
*/
|
|
67
|
+
declare function stringListFlagPreset<TKey extends string>(config: StringListFlagPresetConfig<TKey>): FlagPreset<{ [K in TKey] : string[] | undefined }>;
|
|
68
|
+
/**
|
|
47
69
|
* Verbose output flag preset.
|
|
48
70
|
*
|
|
49
71
|
* Adds: `-v, --verbose`
|
|
@@ -164,4 +186,4 @@ declare function executionPreset(config?: ExecutionPresetConfig): FlagPreset<Exe
|
|
|
164
186
|
* `@outfitter/cli/pagination`.
|
|
165
187
|
*/
|
|
166
188
|
declare function paginationPreset(config?: PaginationPresetConfig): FlagPreset<PaginationFlags>;
|
|
167
|
-
export { verbosePreset, timeWindowPreset, strictPreset, projectionPreset, paginationPreset, interactionPreset, forcePreset, executionPreset, dryRunPreset, cwdPreset, createPreset, composePresets, colorPreset, TimeWindowPresetConfig, TimeWindowFlags, StrictFlags, ProjectionFlags, PaginationPresetConfig, PaginationFlags, InteractionFlags, FlagPresetConfig, FlagPreset, ExecutionPresetConfig, ExecutionFlags, ComposedPreset, ColorMode, ColorFlags };
|
|
189
|
+
export { verbosePreset, timeWindowPreset, stringListFlagPreset, strictPreset, projectionPreset, paginationPreset, numberFlagPreset, interactionPreset, forcePreset, executionPreset, enumFlagPreset, dryRunPreset, cwdPreset, createPreset, composePresets, colorPreset, booleanFlagPreset, TimeWindowPresetConfig, TimeWindowFlags, StringListFlagPresetConfig, StrictFlags, ProjectionFlags, PaginationPresetConfig, PaginationFlags, NumberFlagPresetConfig, InteractionFlags, FlagPresetConfig, FlagPreset, ExecutionPresetConfig, ExecutionFlags, EnumFlagPresetConfig, ComposedPreset, ColorMode, ColorFlags, BooleanFlagPresetConfig };
|
package/dist/flags.js
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
+
booleanFlagPreset,
|
|
3
4
|
colorPreset,
|
|
4
5
|
composePresets,
|
|
5
6
|
createPreset,
|
|
6
7
|
cwdPreset,
|
|
7
8
|
dryRunPreset,
|
|
9
|
+
enumFlagPreset,
|
|
8
10
|
executionPreset,
|
|
9
11
|
forcePreset,
|
|
10
12
|
interactionPreset,
|
|
13
|
+
numberFlagPreset,
|
|
11
14
|
paginationPreset,
|
|
12
15
|
projectionPreset,
|
|
13
16
|
strictPreset,
|
|
17
|
+
stringListFlagPreset,
|
|
14
18
|
timeWindowPreset,
|
|
15
19
|
verbosePreset
|
|
16
|
-
} from "./shared/@outfitter/cli-
|
|
20
|
+
} from "./shared/@outfitter/cli-pdb7znbq.js";
|
|
17
21
|
export {
|
|
18
22
|
verbosePreset,
|
|
19
23
|
timeWindowPreset,
|
|
24
|
+
stringListFlagPreset,
|
|
20
25
|
strictPreset,
|
|
21
26
|
projectionPreset,
|
|
22
27
|
paginationPreset,
|
|
28
|
+
numberFlagPreset,
|
|
23
29
|
interactionPreset,
|
|
24
30
|
forcePreset,
|
|
25
31
|
executionPreset,
|
|
32
|
+
enumFlagPreset,
|
|
26
33
|
dryRunPreset,
|
|
27
34
|
cwdPreset,
|
|
28
35
|
createPreset,
|
|
29
36
|
composePresets,
|
|
30
|
-
colorPreset
|
|
37
|
+
colorPreset,
|
|
38
|
+
booleanFlagPreset
|
|
31
39
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./shared/@outfitter/cli-qz47jk6d";
|
|
2
|
-
import { ANSI, Theme, Tokens, createTheme } from "./shared/@outfitter/cli-
|
|
3
|
-
import { exitWithError, output } from "./shared/@outfitter/cli-
|
|
4
|
-
import { OutputMode } from "./shared/@outfitter/cli-
|
|
1
|
+
import "./shared/@outfitter/cli-qz47jk6d.js";
|
|
2
|
+
import { ANSI, Theme, Tokens, createTheme } from "./shared/@outfitter/cli-j2x88att.js";
|
|
3
|
+
import { exitWithError, output } from "./shared/@outfitter/cli-xy3gs50c.js";
|
|
4
|
+
import { OutputMode } from "./shared/@outfitter/cli-98aa9104.js";
|
|
5
5
|
export { output, exitWithError, createTheme, Tokens, Theme, OutputMode, ANSI };
|
package/dist/input.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectIdsOptions, ExpandFileOptions, FilterExpression, KeyValuePair, NormalizeIdOptions, ParseGlobOptions, Range, SortCriteria } from "./shared/@outfitter/cli-
|
|
1
|
+
import { CollectIdsOptions, ExpandFileOptions, FilterExpression, KeyValuePair, NormalizeIdOptions, ParseGlobOptions, Range, SortCriteria } from "./shared/@outfitter/cli-98aa9104.js";
|
|
2
2
|
import { ValidationError } from "@outfitter/contracts";
|
|
3
3
|
import { Result } from "better-result";
|
|
4
4
|
/**
|
package/dist/output.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-
|
|
2
|
-
import "./shared/@outfitter/cli-
|
|
1
|
+
import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-xy3gs50c.js";
|
|
2
|
+
import "./shared/@outfitter/cli-98aa9104.js";
|
|
3
3
|
export { resolveVerbose, output, exitWithError };
|
package/dist/pagination.d.ts
CHANGED
package/dist/query.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FlagPreset, OutputMode } from "./shared/@outfitter/cli-
|
|
1
|
+
import { FlagPreset, OutputMode } from "./shared/@outfitter/cli-98aa9104.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the output mode preset.
|
|
4
4
|
*/
|
|
5
5
|
interface OutputModePresetConfig {
|
|
6
|
-
/** Allowed output modes (default: ["human", "json"]) */
|
|
7
|
-
readonly modes?: readonly OutputMode[];
|
|
8
6
|
/** Default mode when not specified (default: "human") */
|
|
9
7
|
readonly defaultMode?: OutputMode;
|
|
10
8
|
/** Whether to include "jsonl" in allowed modes (default: false) */
|
|
11
9
|
readonly includeJsonl?: boolean;
|
|
10
|
+
/** Allowed output modes (default: ["human", "json"]) */
|
|
11
|
+
readonly modes?: readonly OutputMode[];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Resolved output mode from CLI input.
|
package/dist/query.js
CHANGED
package/dist/schema.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ActionManifest, ActionManifestEntry, ActionSource, GenerateManifestOptions, SchemaCommandOptions, SurfaceCommandOptions, createSchemaCommand, formatManifestHuman, generateManifest } from "./shared/@outfitter/cli-n1k0d23k";
|
|
1
|
+
import { ActionManifest, ActionManifestEntry, ActionSource, GenerateManifestOptions, SchemaCommandOptions, SurfaceCommandOptions, createSchemaCommand, formatManifestHuman, generateManifest } from "./shared/@outfitter/cli-n1k0d23k.js";
|
|
2
2
|
export { generateManifest, formatManifestHuman, createSchemaCommand, SurfaceCommandOptions, SchemaCommandOptions, GenerateManifestOptions, ActionSource, ActionManifestEntry, ActionManifest };
|
package/dist/schema.js
CHANGED
|
@@ -42,9 +42,9 @@ function formatSummary(manifest, programName) {
|
|
|
42
42
|
for (const [groupName, groupActions] of grouped.entries()) {
|
|
43
43
|
lines.push(groupName);
|
|
44
44
|
for (const action of groupActions) {
|
|
45
|
-
const commandPart = action.cli?.command ??
|
|
45
|
+
const commandPart = action.cli?.command ?? "";
|
|
46
46
|
const isBase = !commandPart || commandPart.startsWith("[") || commandPart.startsWith("<");
|
|
47
|
-
const displayCommand = isBase ? ` ${groupName} ${commandPart
|
|
47
|
+
const displayCommand = isBase ? ` ${groupName} ${commandPart}`.trimEnd() : ` ${groupName} ${commandPart}`;
|
|
48
48
|
const desc = action.cli?.description ?? action.description ?? "";
|
|
49
49
|
lines.push(padCommand(displayCommand, desc));
|
|
50
50
|
}
|
|
@@ -76,8 +76,8 @@ function formatActionDetail(manifest, actionId) {
|
|
|
76
76
|
lines.push("");
|
|
77
77
|
if (entry.cli) {
|
|
78
78
|
const group = entry.cli.group;
|
|
79
|
-
const commandPart = entry.cli.command ?? entry.id;
|
|
80
|
-
const fullCommand = group ? `${group} ${commandPart}
|
|
79
|
+
const commandPart = entry.cli.command ?? (group ? "" : entry.id);
|
|
80
|
+
const fullCommand = group ? `${group} ${commandPart}`.trimEnd() : commandPart;
|
|
81
81
|
lines.push(` Command: ${fullCommand}`);
|
|
82
82
|
}
|
|
83
83
|
lines.push(` Surfaces: ${entry.surfaces.join(", ")}`);
|
|
@@ -15,40 +15,40 @@ import { Result } from "better-result";
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
interface CLIConfig {
|
|
18
|
-
/** CLI name (used in help output and error messages) */
|
|
19
|
-
readonly name: string;
|
|
20
|
-
/** CLI version (displayed with --version) */
|
|
21
|
-
readonly version: string;
|
|
22
18
|
/** CLI description (displayed in help output) */
|
|
23
19
|
readonly description?: string;
|
|
20
|
+
/** CLI name (used in help output and error messages) */
|
|
21
|
+
readonly name: string;
|
|
24
22
|
/** Custom error handler */
|
|
25
23
|
readonly onError?: (error: Error) => void;
|
|
26
24
|
/** Custom exit handler (defaults to process.exit) */
|
|
27
25
|
readonly onExit?: (code: number) => void | Promise<void>;
|
|
26
|
+
/** CLI version (displayed with --version) */
|
|
27
|
+
readonly version: string;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* CLI instance returned by createCLI.
|
|
31
31
|
*/
|
|
32
32
|
interface CLI {
|
|
33
|
-
/** Register a command with the CLI */
|
|
34
|
-
register(command: CommandBuilder | Command): this;
|
|
35
33
|
/** Parse arguments and execute the matched command */
|
|
36
34
|
parse(argv?: readonly string[]): Promise<void>;
|
|
37
35
|
/** Get the underlying Commander program */
|
|
38
36
|
readonly program: Command;
|
|
37
|
+
/** Register a command with the CLI */
|
|
38
|
+
register(command: CommandBuilder | Command): this;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Configuration for a single command.
|
|
42
42
|
*/
|
|
43
43
|
interface CommandConfig {
|
|
44
|
-
/** Command name and argument syntax (e.g., "list" or "get <id>") */
|
|
45
|
-
readonly name: string;
|
|
46
|
-
/** Command description */
|
|
47
|
-
readonly description?: string;
|
|
48
44
|
/** Command aliases */
|
|
49
45
|
readonly aliases?: readonly string[];
|
|
46
|
+
/** Command description */
|
|
47
|
+
readonly description?: string;
|
|
50
48
|
/** Whether to hide from help output */
|
|
51
49
|
readonly hidden?: boolean;
|
|
50
|
+
/** Command name and argument syntax (e.g., "list" or "get <id>") */
|
|
51
|
+
readonly name: string;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Action function executed when a command is invoked.
|
|
@@ -72,44 +72,44 @@ type CommandFlags = Record<string, unknown>;
|
|
|
72
72
|
* Builder interface for constructing commands fluently.
|
|
73
73
|
*/
|
|
74
74
|
interface CommandBuilder {
|
|
75
|
+
/** Set the action handler */
|
|
76
|
+
action<TFlags extends CommandFlags = CommandFlags>(handler: CommandAction<TFlags>): this;
|
|
77
|
+
/** Add command aliases */
|
|
78
|
+
alias(alias: string): this;
|
|
79
|
+
/** Build the underlying Commander command */
|
|
80
|
+
build(): Command;
|
|
75
81
|
/** Set command description */
|
|
76
82
|
description(text: string): this;
|
|
77
83
|
/** Add a command option/flag */
|
|
78
84
|
option(flags: string, description: string, defaultValue?: unknown): this;
|
|
79
|
-
/** Add a required option */
|
|
80
|
-
requiredOption(flags: string, description: string, defaultValue?: unknown): this;
|
|
81
|
-
/** Add command aliases */
|
|
82
|
-
alias(alias: string): this;
|
|
83
85
|
/** Apply a flag preset (adds its options to the command) */
|
|
84
86
|
preset(preset: FlagPreset<Record<string, unknown>>): this;
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
/** Build the underlying Commander command */
|
|
88
|
-
build(): Command;
|
|
87
|
+
/** Add a required option */
|
|
88
|
+
requiredOption(flags: string, description: string, defaultValue?: unknown): this;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* A family of related command verbs with a primary name and aliases.
|
|
92
92
|
*/
|
|
93
93
|
interface VerbFamily {
|
|
94
|
-
/** Primary verb name */
|
|
95
|
-
readonly primary: string;
|
|
96
94
|
/** Alternative names for this verb */
|
|
97
95
|
readonly aliases: readonly string[];
|
|
98
96
|
/** Description of what this verb family does */
|
|
99
97
|
readonly description: string;
|
|
98
|
+
/** Primary verb name */
|
|
99
|
+
readonly primary: string;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Configuration for resolving a verb family with project-level overrides.
|
|
103
103
|
*/
|
|
104
104
|
interface VerbConfig {
|
|
105
|
-
/** Override the primary verb (e.g., "edit" instead of "modify") */
|
|
106
|
-
readonly primary?: string;
|
|
107
105
|
/** Whether to include aliases (default: true) */
|
|
108
106
|
readonly aliases?: boolean;
|
|
109
|
-
/** Additional aliases beyond defaults */
|
|
110
|
-
readonly extraAliases?: readonly string[];
|
|
111
107
|
/** Aliases to exclude */
|
|
112
108
|
readonly excludeAliases?: readonly string[];
|
|
109
|
+
/** Additional aliases beyond defaults */
|
|
110
|
+
readonly extraAliases?: readonly string[];
|
|
111
|
+
/** Override the primary verb (e.g., "edit" instead of "modify") */
|
|
112
|
+
readonly primary?: string;
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* A composable set of CLI flags with typed resolution.
|
|
@@ -137,6 +137,99 @@ interface FlagPresetConfig<TResolved extends Record<string, unknown>> {
|
|
|
137
137
|
readonly resolve: (flags: Record<string, unknown>) => TResolved;
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
+
* Configuration for creating a custom boolean flag preset.
|
|
141
|
+
*/
|
|
142
|
+
interface BooleanFlagPresetConfig<TKey extends string> {
|
|
143
|
+
/** Default resolved value (defaults to false) */
|
|
144
|
+
readonly defaultValue?: boolean;
|
|
145
|
+
/** Help description for the option */
|
|
146
|
+
readonly description: string;
|
|
147
|
+
/** Commander option definition (e.g., "--force" or "--no-codemods") */
|
|
148
|
+
readonly flags: string;
|
|
149
|
+
/** Unique identifier for deduplication */
|
|
150
|
+
readonly id: string;
|
|
151
|
+
/** Resolved output property name */
|
|
152
|
+
readonly key: TKey;
|
|
153
|
+
/** Positive keys that should be negated (e.g., "codemods" for --no-codemods) */
|
|
154
|
+
readonly negatedSources?: readonly string[];
|
|
155
|
+
/** Whether the option is required */
|
|
156
|
+
readonly required?: boolean;
|
|
157
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
158
|
+
readonly sources?: readonly string[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for creating a custom enum flag preset.
|
|
162
|
+
*/
|
|
163
|
+
interface EnumFlagPresetConfig<
|
|
164
|
+
TKey extends string,
|
|
165
|
+
TValue extends string
|
|
166
|
+
> {
|
|
167
|
+
/** Fallback value when input is missing or invalid */
|
|
168
|
+
readonly defaultValue: TValue;
|
|
169
|
+
/** Help description for the option */
|
|
170
|
+
readonly description: string;
|
|
171
|
+
/** Commander option definition */
|
|
172
|
+
readonly flags: string;
|
|
173
|
+
/** Unique identifier for deduplication */
|
|
174
|
+
readonly id: string;
|
|
175
|
+
/** Resolved output property name */
|
|
176
|
+
readonly key: TKey;
|
|
177
|
+
/** Whether the option is required */
|
|
178
|
+
readonly required?: boolean;
|
|
179
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
180
|
+
readonly sources?: readonly string[];
|
|
181
|
+
/** Allowed enum values */
|
|
182
|
+
readonly values: readonly TValue[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for creating a custom numeric flag preset.
|
|
186
|
+
*/
|
|
187
|
+
interface NumberFlagPresetConfig<TKey extends string> {
|
|
188
|
+
/** Fallback value when input is missing or invalid */
|
|
189
|
+
readonly defaultValue: number;
|
|
190
|
+
/** Help description for the option */
|
|
191
|
+
readonly description: string;
|
|
192
|
+
/** Commander option definition */
|
|
193
|
+
readonly flags: string;
|
|
194
|
+
/** Unique identifier for deduplication */
|
|
195
|
+
readonly id: string;
|
|
196
|
+
/** Floor parsed values (defaults to true) */
|
|
197
|
+
readonly integer?: boolean;
|
|
198
|
+
/** Resolved output property name */
|
|
199
|
+
readonly key: TKey;
|
|
200
|
+
/** Upper bound (inclusive) */
|
|
201
|
+
readonly max?: number;
|
|
202
|
+
/** Lower bound (inclusive) */
|
|
203
|
+
readonly min?: number;
|
|
204
|
+
/** Whether the option is required */
|
|
205
|
+
readonly required?: boolean;
|
|
206
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
207
|
+
readonly sources?: readonly string[];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Configuration for creating a custom string-list flag preset.
|
|
211
|
+
*/
|
|
212
|
+
interface StringListFlagPresetConfig<TKey extends string> {
|
|
213
|
+
/** Remove duplicate values while preserving order */
|
|
214
|
+
readonly dedupe?: boolean;
|
|
215
|
+
/** Fallback list when input is missing or invalid */
|
|
216
|
+
readonly defaultValue?: readonly string[];
|
|
217
|
+
/** Help description for the option */
|
|
218
|
+
readonly description: string;
|
|
219
|
+
/** Commander option definition */
|
|
220
|
+
readonly flags: string;
|
|
221
|
+
/** Unique identifier for deduplication */
|
|
222
|
+
readonly id: string;
|
|
223
|
+
/** Resolved output property name */
|
|
224
|
+
readonly key: TKey;
|
|
225
|
+
/** Whether the option is required */
|
|
226
|
+
readonly required?: boolean;
|
|
227
|
+
/** Split string values by this separator (defaults to ",") */
|
|
228
|
+
readonly separator?: string;
|
|
229
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
230
|
+
readonly sources?: readonly string[];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
140
233
|
* Result of composing multiple presets together.
|
|
141
234
|
* Options are deduplicated by preset id (first wins).
|
|
142
235
|
*/
|
|
@@ -197,10 +290,10 @@ type ExecutionFlags = {
|
|
|
197
290
|
* Configuration for the execution flag preset.
|
|
198
291
|
*/
|
|
199
292
|
interface ExecutionPresetConfig {
|
|
200
|
-
/** Default timeout in milliseconds (default: undefined) */
|
|
201
|
-
readonly defaultTimeout?: number;
|
|
202
293
|
/** Default number of retries (default: 0) */
|
|
203
294
|
readonly defaultRetries?: number;
|
|
295
|
+
/** Default timeout in milliseconds (default: undefined) */
|
|
296
|
+
readonly defaultTimeout?: number;
|
|
204
297
|
/** Maximum number of retries (default: 10) */
|
|
205
298
|
readonly maxRetries?: number;
|
|
206
299
|
}
|
|
@@ -245,14 +338,14 @@ type OutputMode = "human" | "json" | "jsonl" | "tree" | "table";
|
|
|
245
338
|
* Options for the output() function.
|
|
246
339
|
*/
|
|
247
340
|
interface OutputOptions {
|
|
341
|
+
/** Exit code to use after output (undefined = don't exit) */
|
|
342
|
+
readonly exitCode?: number;
|
|
248
343
|
/** Force a specific output mode (overrides flag detection) */
|
|
249
344
|
readonly mode?: OutputMode;
|
|
250
|
-
/** Stream to write to (defaults to stdout) */
|
|
251
|
-
readonly stream?: NodeJS.WritableStream;
|
|
252
345
|
/** Whether to pretty-print JSON output */
|
|
253
346
|
readonly pretty?: boolean;
|
|
254
|
-
/**
|
|
255
|
-
readonly
|
|
347
|
+
/** Stream to write to (defaults to stdout) */
|
|
348
|
+
readonly stream?: NodeJS.WritableStream;
|
|
256
349
|
}
|
|
257
350
|
/**
|
|
258
351
|
* Options for collectIds() input utility.
|
|
@@ -296,10 +389,10 @@ interface ParseGlobOptions {
|
|
|
296
389
|
readonly followSymlinks?: boolean;
|
|
297
390
|
/** Patterns to exclude */
|
|
298
391
|
readonly ignore?: readonly string[];
|
|
299
|
-
/** Only match files (not directories) */
|
|
300
|
-
readonly onlyFiles?: boolean;
|
|
301
392
|
/** Only match directories (not files) */
|
|
302
393
|
readonly onlyDirectories?: boolean;
|
|
394
|
+
/** Only match files (not directories) */
|
|
395
|
+
readonly onlyFiles?: boolean;
|
|
303
396
|
}
|
|
304
397
|
/**
|
|
305
398
|
* Options for normalizeId().
|
|
@@ -307,14 +400,14 @@ interface ParseGlobOptions {
|
|
|
307
400
|
interface NormalizeIdOptions {
|
|
308
401
|
/** Whether to lowercase the ID */
|
|
309
402
|
readonly lowercase?: boolean;
|
|
310
|
-
/** Whether to trim whitespace */
|
|
311
|
-
readonly trim?: boolean;
|
|
312
|
-
/** Minimum length requirement */
|
|
313
|
-
readonly minLength?: number;
|
|
314
403
|
/** Maximum length requirement */
|
|
315
404
|
readonly maxLength?: number;
|
|
405
|
+
/** Minimum length requirement */
|
|
406
|
+
readonly minLength?: number;
|
|
316
407
|
/** Pattern the ID must match */
|
|
317
408
|
readonly pattern?: RegExp;
|
|
409
|
+
/** Whether to trim whitespace */
|
|
410
|
+
readonly trim?: boolean;
|
|
318
411
|
}
|
|
319
412
|
/**
|
|
320
413
|
* Numeric or date range parsed from CLI input.
|
|
@@ -324,32 +417,32 @@ type Range = NumericRange | DateRange;
|
|
|
324
417
|
* Numeric range (e.g., "1-10").
|
|
325
418
|
*/
|
|
326
419
|
interface NumericRange {
|
|
327
|
-
readonly type: "number";
|
|
328
|
-
readonly min: number;
|
|
329
420
|
readonly max: number;
|
|
421
|
+
readonly min: number;
|
|
422
|
+
readonly type: "number";
|
|
330
423
|
}
|
|
331
424
|
/**
|
|
332
425
|
* Date range (e.g., "2024-01-01..2024-12-31").
|
|
333
426
|
*/
|
|
334
427
|
interface DateRange {
|
|
335
|
-
readonly type: "date";
|
|
336
|
-
readonly start: Date;
|
|
337
428
|
readonly end: Date;
|
|
429
|
+
readonly start: Date;
|
|
430
|
+
readonly type: "date";
|
|
338
431
|
}
|
|
339
432
|
/**
|
|
340
433
|
* Filter expression parsed from CLI input.
|
|
341
434
|
*/
|
|
342
435
|
interface FilterExpression {
|
|
343
436
|
readonly field: string;
|
|
344
|
-
readonly value: string;
|
|
345
437
|
readonly operator?: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "contains";
|
|
438
|
+
readonly value: string;
|
|
346
439
|
}
|
|
347
440
|
/**
|
|
348
441
|
* Sort criteria parsed from CLI input.
|
|
349
442
|
*/
|
|
350
443
|
interface SortCriteria {
|
|
351
|
-
readonly field: string;
|
|
352
444
|
readonly direction: "asc" | "desc";
|
|
445
|
+
readonly field: string;
|
|
353
446
|
}
|
|
354
447
|
/**
|
|
355
448
|
* Key-value pair parsed from CLI input.
|
|
@@ -362,16 +455,16 @@ interface KeyValuePair {
|
|
|
362
455
|
* State for paginated command results.
|
|
363
456
|
*/
|
|
364
457
|
interface PaginationState {
|
|
365
|
-
/** Cursor for the next page */
|
|
366
|
-
readonly cursor: string;
|
|
367
458
|
/** Command that generated this state */
|
|
368
459
|
readonly command: string;
|
|
369
460
|
/** Context key for scoping pagination */
|
|
370
461
|
readonly context?: string;
|
|
371
|
-
/**
|
|
372
|
-
readonly
|
|
462
|
+
/** Cursor for the next page */
|
|
463
|
+
readonly cursor: string;
|
|
373
464
|
/** Whether there are more results */
|
|
374
465
|
readonly hasMore: boolean;
|
|
466
|
+
/** Timestamp when state was created */
|
|
467
|
+
readonly timestamp: number;
|
|
375
468
|
/** Total count (if known) */
|
|
376
469
|
readonly total?: number;
|
|
377
470
|
}
|
|
@@ -383,13 +476,13 @@ interface CursorOptions {
|
|
|
383
476
|
readonly command: string;
|
|
384
477
|
/** Context key for additional scoping */
|
|
385
478
|
readonly context?: string;
|
|
386
|
-
/** Tool name for XDG path resolution */
|
|
387
|
-
readonly toolName: string;
|
|
388
|
-
/** Maximum age in milliseconds before a cursor is treated as expired */
|
|
389
|
-
readonly maxAgeMs?: number;
|
|
390
479
|
/** Whether there are more results (defaults to true) */
|
|
391
480
|
readonly hasMore?: boolean;
|
|
481
|
+
/** Maximum age in milliseconds before a cursor is treated as expired */
|
|
482
|
+
readonly maxAgeMs?: number;
|
|
483
|
+
/** Tool name for XDG path resolution */
|
|
484
|
+
readonly toolName: string;
|
|
392
485
|
/** Total count of results (if known) */
|
|
393
486
|
readonly total?: number;
|
|
394
487
|
}
|
|
395
|
-
export { CLIConfig, CLI, CommandConfig, CommandAction, CommandFlags, CommandBuilder, VerbFamily, VerbConfig, FlagPreset, FlagPresetConfig, ComposedPreset, PaginationPresetConfig, InteractionFlags, StrictFlags, TimeWindowFlags, TimeWindowPresetConfig, ExecutionFlags, ExecutionPresetConfig, ProjectionFlags, ColorMode, ColorFlags, PaginationFlags, OutputMode, OutputOptions, CollectIdsOptions, ExpandFileOptions, ParseGlobOptions, NormalizeIdOptions, Range, NumericRange, DateRange, FilterExpression, SortCriteria, KeyValuePair, PaginationState, CursorOptions, CancelledError, ErrorCategory, ValidationError, Result };
|
|
488
|
+
export { CLIConfig, CLI, CommandConfig, CommandAction, CommandFlags, CommandBuilder, VerbFamily, VerbConfig, FlagPreset, FlagPresetConfig, BooleanFlagPresetConfig, EnumFlagPresetConfig, NumberFlagPresetConfig, StringListFlagPresetConfig, ComposedPreset, PaginationPresetConfig, InteractionFlags, StrictFlags, TimeWindowFlags, TimeWindowPresetConfig, ExecutionFlags, ExecutionPresetConfig, ProjectionFlags, ColorMode, ColorFlags, PaginationFlags, OutputMode, OutputOptions, CollectIdsOptions, ExpandFileOptions, ParseGlobOptions, NormalizeIdOptions, Range, NumericRange, DateRange, FilterExpression, SortCriteria, KeyValuePair, PaginationState, CursorOptions, CancelledError, ErrorCategory, ValidationError, Result };
|
|
@@ -46,6 +46,149 @@ function composePresets(...presets) {
|
|
|
46
46
|
composed[PRESET_IDS] = mergedIds;
|
|
47
47
|
return composed;
|
|
48
48
|
}
|
|
49
|
+
function resolveSourceKeys(key, sources) {
|
|
50
|
+
return sources && sources.length > 0 ? sources : [key];
|
|
51
|
+
}
|
|
52
|
+
function booleanFlagPreset(config) {
|
|
53
|
+
const sources = resolveSourceKeys(config.key, config.sources);
|
|
54
|
+
const defaultValue = config.defaultValue ?? false;
|
|
55
|
+
const isNegatedFlag = config.flags.includes("--no-");
|
|
56
|
+
const optionDefault = isNegatedFlag && config.defaultValue === undefined ? {} : { defaultValue };
|
|
57
|
+
return createPreset({
|
|
58
|
+
id: config.id,
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
flags: config.flags,
|
|
62
|
+
description: config.description,
|
|
63
|
+
...optionDefault,
|
|
64
|
+
...config.required === true ? { required: true } : {}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
resolve: (flags) => {
|
|
68
|
+
for (const source of sources) {
|
|
69
|
+
const value = flags[source];
|
|
70
|
+
if (typeof value === "boolean") {
|
|
71
|
+
return { [config.key]: value };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (config.negatedSources) {
|
|
75
|
+
for (const source of config.negatedSources) {
|
|
76
|
+
const value = flags[source];
|
|
77
|
+
if (typeof value === "boolean") {
|
|
78
|
+
return { [config.key]: !value };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { [config.key]: defaultValue };
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function enumFlagPreset(config) {
|
|
87
|
+
const sources = resolveSourceKeys(config.key, config.sources);
|
|
88
|
+
const allowed = new Set(config.values);
|
|
89
|
+
return createPreset({
|
|
90
|
+
id: config.id,
|
|
91
|
+
options: [
|
|
92
|
+
{
|
|
93
|
+
flags: config.flags,
|
|
94
|
+
description: config.description,
|
|
95
|
+
...config.required === true ? { required: true } : {}
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
resolve: (flags) => {
|
|
99
|
+
for (const source of sources) {
|
|
100
|
+
const value = flags[source];
|
|
101
|
+
if (typeof value === "string" && allowed.has(value)) {
|
|
102
|
+
return { [config.key]: value };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
[config.key]: config.defaultValue
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function numberFlagPreset(config) {
|
|
112
|
+
const sources = resolveSourceKeys(config.key, config.sources);
|
|
113
|
+
return createPreset({
|
|
114
|
+
id: config.id,
|
|
115
|
+
options: [
|
|
116
|
+
{
|
|
117
|
+
flags: config.flags,
|
|
118
|
+
description: config.description,
|
|
119
|
+
...config.required === true ? { required: true } : {}
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
resolve: (flags) => {
|
|
123
|
+
let parsed;
|
|
124
|
+
for (const source of sources) {
|
|
125
|
+
const value = flags[source];
|
|
126
|
+
if (value === "" || value == null || typeof value === "boolean") {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const numeric = Number(value);
|
|
130
|
+
if (Number.isFinite(numeric)) {
|
|
131
|
+
parsed = config.integer === false ? numeric : Math.floor(numeric);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (parsed === undefined) {
|
|
136
|
+
parsed = config.defaultValue;
|
|
137
|
+
}
|
|
138
|
+
if (typeof config.min === "number" && Number.isFinite(config.min)) {
|
|
139
|
+
parsed = Math.max(parsed, config.min);
|
|
140
|
+
}
|
|
141
|
+
if (typeof config.max === "number" && Number.isFinite(config.max)) {
|
|
142
|
+
parsed = Math.min(parsed, config.max);
|
|
143
|
+
}
|
|
144
|
+
return { [config.key]: parsed };
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function normalizeStringListInput(value, separator) {
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
const items2 = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
|
|
151
|
+
return items2.length > 0 ? items2 : undefined;
|
|
152
|
+
}
|
|
153
|
+
if (typeof value !== "string")
|
|
154
|
+
return;
|
|
155
|
+
const items = value.split(separator).map((item) => item.trim()).filter(Boolean);
|
|
156
|
+
return items.length > 0 ? items : undefined;
|
|
157
|
+
}
|
|
158
|
+
function stringListFlagPreset(config) {
|
|
159
|
+
const sources = resolveSourceKeys(config.key, config.sources);
|
|
160
|
+
const separator = config.separator ?? ",";
|
|
161
|
+
const fallback = config.defaultValue === undefined ? undefined : [...config.defaultValue];
|
|
162
|
+
return createPreset({
|
|
163
|
+
id: config.id,
|
|
164
|
+
options: [
|
|
165
|
+
{
|
|
166
|
+
flags: config.flags,
|
|
167
|
+
description: config.description,
|
|
168
|
+
...config.required === true ? { required: true } : {}
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
resolve: (flags) => {
|
|
172
|
+
let resolved;
|
|
173
|
+
for (const source of sources) {
|
|
174
|
+
const parsed = normalizeStringListInput(flags[source], separator);
|
|
175
|
+
if (parsed !== undefined) {
|
|
176
|
+
resolved = parsed;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (resolved === undefined) {
|
|
181
|
+
resolved = fallback === undefined ? undefined : [...fallback];
|
|
182
|
+
}
|
|
183
|
+
if (resolved && config.dedupe) {
|
|
184
|
+
resolved = [...new Set(resolved)];
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
[config.key]: resolved
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
49
192
|
function verbosePreset() {
|
|
50
193
|
return createPreset({
|
|
51
194
|
id: "verbose",
|
|
@@ -354,4 +497,4 @@ function paginationPreset(config) {
|
|
|
354
497
|
});
|
|
355
498
|
}
|
|
356
499
|
|
|
357
|
-
export { createPreset, composePresets, verbosePreset, cwdPreset, dryRunPreset, forcePreset, interactionPreset, strictPreset, colorPreset, projectionPreset, timeWindowPreset, executionPreset, paginationPreset };
|
|
500
|
+
export { createPreset, composePresets, booleanFlagPreset, enumFlagPreset, numberFlagPreset, stringListFlagPreset, verbosePreset, cwdPreset, dryRunPreset, forcePreset, interactionPreset, strictPreset, colorPreset, projectionPreset, timeWindowPreset, executionPreset, paginationPreset };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TerminalOptions, getEnvValue, getTerminalWidth, hasNoColorEnv, isInteractive, resolveColorEnv, resolveForceColorEnv, supportsColor } from "../shared/@outfitter/cli-
|
|
1
|
+
import { TerminalOptions, getEnvValue, getTerminalWidth, hasNoColorEnv, isInteractive, resolveColorEnv, resolveForceColorEnv, supportsColor } from "../shared/@outfitter/cli-rr1sq5s4.js";
|
|
2
2
|
export { supportsColor, resolveForceColorEnv, resolveColorEnv, isInteractive, hasNoColorEnv, getTerminalWidth, getEnvValue, TerminalOptions };
|
package/dist/terminal/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TerminalOptions, getEnvValue, getTerminalWidth, hasNoColorEnv, isInteractive, resolveColorEnv, resolveForceColorEnv, supportsColor } from "../shared/@outfitter/cli-
|
|
1
|
+
import { TerminalOptions, getEnvValue, getTerminalWidth, hasNoColorEnv, isInteractive, resolveColorEnv, resolveForceColorEnv, supportsColor } from "../shared/@outfitter/cli-rr1sq5s4.js";
|
|
2
2
|
export { supportsColor, resolveForceColorEnv, resolveColorEnv, isInteractive, hasNoColorEnv, getTerminalWidth, getEnvValue, TerminalOptions };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CLI, CLIConfig, CancelledError, CollectIdsOptions, ColorFlags, ColorMode, CommandAction, CommandBuilder, CommandConfig, CommandFlags, ComposedPreset, CursorOptions, DateRange, ErrorCategory, ExecutionFlags, ExecutionPresetConfig, ExpandFileOptions, FilterExpression, FlagPreset, FlagPresetConfig, InteractionFlags, KeyValuePair, NormalizeIdOptions, NumericRange, OutputMode, OutputOptions, PaginationFlags, PaginationPresetConfig, PaginationState, ParseGlobOptions, ProjectionFlags, Range, Result, SortCriteria, StrictFlags, TimeWindowFlags, TimeWindowPresetConfig, ValidationError, VerbConfig, VerbFamily } from "./shared/@outfitter/cli-
|
|
2
|
-
export { VerbFamily, VerbConfig, ValidationError, TimeWindowPresetConfig, TimeWindowFlags, StrictFlags, SortCriteria, Result, Range, ProjectionFlags, ParseGlobOptions, PaginationState, PaginationPresetConfig, PaginationFlags, OutputOptions, OutputMode, NumericRange, NormalizeIdOptions, KeyValuePair, InteractionFlags, FlagPresetConfig, FlagPreset, FilterExpression, ExpandFileOptions, ExecutionPresetConfig, ExecutionFlags, ErrorCategory, DateRange, CursorOptions, ComposedPreset, CommandFlags, CommandConfig, CommandBuilder, CommandAction, ColorMode, ColorFlags, CollectIdsOptions, CancelledError, CLIConfig, CLI };
|
|
1
|
+
import { BooleanFlagPresetConfig, CLI, CLIConfig, CancelledError, CollectIdsOptions, ColorFlags, ColorMode, CommandAction, CommandBuilder, CommandConfig, CommandFlags, ComposedPreset, CursorOptions, DateRange, EnumFlagPresetConfig, ErrorCategory, ExecutionFlags, ExecutionPresetConfig, ExpandFileOptions, FilterExpression, FlagPreset, FlagPresetConfig, InteractionFlags, KeyValuePair, NormalizeIdOptions, NumberFlagPresetConfig, NumericRange, OutputMode, OutputOptions, PaginationFlags, PaginationPresetConfig, PaginationState, ParseGlobOptions, ProjectionFlags, Range, Result, SortCriteria, StrictFlags, StringListFlagPresetConfig, TimeWindowFlags, TimeWindowPresetConfig, ValidationError, VerbConfig, VerbFamily } from "./shared/@outfitter/cli-98aa9104.js";
|
|
2
|
+
export { VerbFamily, VerbConfig, ValidationError, TimeWindowPresetConfig, TimeWindowFlags, StringListFlagPresetConfig, StrictFlags, SortCriteria, Result, Range, ProjectionFlags, ParseGlobOptions, PaginationState, PaginationPresetConfig, PaginationFlags, OutputOptions, OutputMode, NumericRange, NumberFlagPresetConfig, NormalizeIdOptions, KeyValuePair, InteractionFlags, FlagPresetConfig, FlagPreset, FilterExpression, ExpandFileOptions, ExecutionPresetConfig, ExecutionFlags, ErrorCategory, EnumFlagPresetConfig, DateRange, CursorOptions, ComposedPreset, CommandFlags, CommandConfig, CommandBuilder, CommandAction, ColorMode, ColorFlags, CollectIdsOptions, CancelledError, CLIConfig, CLI, BooleanFlagPresetConfig };
|
package/dist/verbs.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outfitter/cli",
|
|
3
3
|
"description": "Typed CLI runtime with terminal detection, rendering, output contracts, and input parsing",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -115,10 +115,11 @@
|
|
|
115
115
|
"lint": "biome lint ./src",
|
|
116
116
|
"lint:fix": "biome lint --write ./src",
|
|
117
117
|
"typecheck": "tsc --noEmit",
|
|
118
|
-
"clean": "rm -rf dist"
|
|
118
|
+
"clean": "rm -rf dist",
|
|
119
|
+
"prepublishOnly": "bun ../../scripts/check-publish-manifest.ts"
|
|
119
120
|
},
|
|
120
121
|
"dependencies": {
|
|
121
|
-
"@clack/prompts": "^0.
|
|
122
|
+
"@clack/prompts": "^1.0.1",
|
|
122
123
|
"better-result": "^2.5.1",
|
|
123
124
|
"commander": "^14.0.2"
|
|
124
125
|
},
|
|
@@ -130,15 +131,15 @@
|
|
|
130
131
|
"zod": "^4.3.5"
|
|
131
132
|
},
|
|
132
133
|
"devDependencies": {
|
|
133
|
-
"@outfitter/config": "0.3.
|
|
134
|
-
"@outfitter/contracts": "0.4.
|
|
135
|
-
"@outfitter/schema": "0.2.
|
|
136
|
-
"@types/bun": "^1.3.
|
|
134
|
+
"@outfitter/config": "0.3.3",
|
|
135
|
+
"@outfitter/contracts": "0.4.1",
|
|
136
|
+
"@outfitter/schema": "0.2.2",
|
|
137
|
+
"@types/bun": "^1.3.9",
|
|
137
138
|
"@types/node": "^25.0.10",
|
|
138
139
|
"typescript": "^5.9.3"
|
|
139
140
|
},
|
|
140
141
|
"engines": {
|
|
141
|
-
"bun": ">=1.3.
|
|
142
|
+
"bun": ">=1.3.9"
|
|
142
143
|
},
|
|
143
144
|
"publishConfig": {
|
|
144
145
|
"access": "public"
|
|
@@ -37,40 +37,40 @@ declare const ANSI: {
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
interface Theme {
|
|
40
|
-
/** Applies
|
|
41
|
-
|
|
42
|
-
/** Applies
|
|
43
|
-
|
|
40
|
+
/** Applies cyan color for interactive elements and highlights */
|
|
41
|
+
accent: (text: string) => string;
|
|
42
|
+
/** Applies bold styling */
|
|
43
|
+
bold: (text: string) => string;
|
|
44
|
+
/** Applies bright red for dangerous actions */
|
|
45
|
+
destructive: (text: string) => string;
|
|
46
|
+
/** Applies dim styling (alias for muted style) */
|
|
47
|
+
dim: (text: string) => string;
|
|
44
48
|
/** Applies red color for error messages */
|
|
45
49
|
error: (text: string) => string;
|
|
50
|
+
/** Applies bold for strong emphasis */
|
|
51
|
+
highlight: (text: string) => string;
|
|
46
52
|
/** Applies blue color for informational messages */
|
|
47
53
|
info: (text: string) => string;
|
|
54
|
+
/** Applies inverse styling (swaps foreground/background) */
|
|
55
|
+
inverse: (text: string) => string;
|
|
56
|
+
/** Applies italic styling */
|
|
57
|
+
italic: (text: string) => string;
|
|
58
|
+
/** Applies cyan + underline for URLs and clickable references */
|
|
59
|
+
link: (text: string) => string;
|
|
60
|
+
/** Applies dim styling for de-emphasized text */
|
|
61
|
+
muted: (text: string) => string;
|
|
48
62
|
/** Returns text unchanged (primary/default text) */
|
|
49
63
|
primary: (text: string) => string;
|
|
50
64
|
/** Applies gray color for secondary text */
|
|
51
65
|
secondary: (text: string) => string;
|
|
52
|
-
/** Applies dim styling for de-emphasized text */
|
|
53
|
-
muted: (text: string) => string;
|
|
54
|
-
/** Applies cyan color for interactive elements and highlights */
|
|
55
|
-
accent: (text: string) => string;
|
|
56
|
-
/** Applies bold for strong emphasis */
|
|
57
|
-
highlight: (text: string) => string;
|
|
58
|
-
/** Applies cyan + underline for URLs and clickable references */
|
|
59
|
-
link: (text: string) => string;
|
|
60
|
-
/** Applies bright red for dangerous actions */
|
|
61
|
-
destructive: (text: string) => string;
|
|
62
66
|
/** Applies dim gray for less prominent text than muted */
|
|
63
67
|
subtle: (text: string) => string;
|
|
64
|
-
/** Applies
|
|
65
|
-
|
|
66
|
-
/** Applies italic styling */
|
|
67
|
-
italic: (text: string) => string;
|
|
68
|
+
/** Applies green color for success messages */
|
|
69
|
+
success: (text: string) => string;
|
|
68
70
|
/** Applies underline styling */
|
|
69
71
|
underline: (text: string) => string;
|
|
70
|
-
/** Applies
|
|
71
|
-
|
|
72
|
-
/** Applies inverse styling (swaps foreground/background) */
|
|
73
|
-
inverse: (text: string) => string;
|
|
72
|
+
/** Applies yellow color for warning messages */
|
|
73
|
+
warning: (text: string) => string;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Available color names for the {@link applyColor} function.
|
|
@@ -104,40 +104,40 @@ type ColorName = "green" | "yellow" | "red" | "blue" | "cyan" | "magenta" | "whi
|
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
interface Tokens {
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
|
|
107
|
+
/** Cyan color for interactive elements and highlights */
|
|
108
|
+
accent: string;
|
|
109
|
+
/** Bold styling */
|
|
110
|
+
bold: string;
|
|
111
|
+
/** Bright red for dangerous actions */
|
|
112
|
+
destructive: string;
|
|
113
|
+
/** Dim styling */
|
|
114
|
+
dim: string;
|
|
111
115
|
/** Red color for error messages */
|
|
112
116
|
error: string;
|
|
117
|
+
/** Bold for strong emphasis */
|
|
118
|
+
highlight: string;
|
|
113
119
|
/** Blue color for informational messages */
|
|
114
120
|
info: string;
|
|
121
|
+
/** Inverse styling (swaps foreground/background) */
|
|
122
|
+
inverse: string;
|
|
123
|
+
/** Italic styling */
|
|
124
|
+
italic: string;
|
|
125
|
+
/** Cyan + underline for URLs and clickable references */
|
|
126
|
+
link: string;
|
|
127
|
+
/** Dim/gray color for de-emphasized text */
|
|
128
|
+
muted: string;
|
|
115
129
|
/** Default text color (typically empty string) */
|
|
116
130
|
primary: string;
|
|
117
131
|
/** Subdued color for secondary text */
|
|
118
132
|
secondary: string;
|
|
119
|
-
/** Dim/gray color for de-emphasized text */
|
|
120
|
-
muted: string;
|
|
121
|
-
/** Cyan color for interactive elements and highlights */
|
|
122
|
-
accent: string;
|
|
123
|
-
/** Bold for strong emphasis */
|
|
124
|
-
highlight: string;
|
|
125
|
-
/** Cyan + underline for URLs and clickable references */
|
|
126
|
-
link: string;
|
|
127
|
-
/** Bright red for dangerous actions */
|
|
128
|
-
destructive: string;
|
|
129
133
|
/** Dim gray for less prominent text than muted */
|
|
130
134
|
subtle: string;
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
/** Italic styling */
|
|
134
|
-
italic: string;
|
|
135
|
+
/** Green color for success messages */
|
|
136
|
+
success: string;
|
|
135
137
|
/** Underline styling */
|
|
136
138
|
underline: string;
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
/** Inverse styling (swaps foreground/background) */
|
|
140
|
-
inverse: string;
|
|
139
|
+
/** Yellow color for warning messages */
|
|
140
|
+
warning: string;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Configuration options for {@link createTokens}.
|
|
@@ -152,11 +152,6 @@ interface Tokens {
|
|
|
152
152
|
* ```
|
|
153
153
|
*/
|
|
154
154
|
interface TokenOptions {
|
|
155
|
-
/**
|
|
156
|
-
* Override NO_COLOR environment variable.
|
|
157
|
-
* When true, colors are enabled regardless of NO_COLOR.
|
|
158
|
-
*/
|
|
159
|
-
forceColor?: boolean;
|
|
160
155
|
/**
|
|
161
156
|
* Color support level:
|
|
162
157
|
* - 0: No color support (all tokens are empty strings)
|
|
@@ -167,6 +162,11 @@ interface TokenOptions {
|
|
|
167
162
|
* When not specified, level is auto-detected from environment.
|
|
168
163
|
*/
|
|
169
164
|
colorLevel?: 0 | 1 | 2 | 3;
|
|
165
|
+
/**
|
|
166
|
+
* Override NO_COLOR environment variable.
|
|
167
|
+
* When true, colors are enabled regardless of NO_COLOR.
|
|
168
|
+
*/
|
|
169
|
+
forceColor?: boolean;
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Creates a theme with semantic and text color functions.
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
interface TerminalOptions {
|
|
17
|
-
/** Override TTY detection (uses process.stdout.isTTY if not specified) */
|
|
18
|
-
isTTY?: boolean;
|
|
19
17
|
/** Override CI detection (uses CI env variable if not specified) */
|
|
20
18
|
isCI?: boolean;
|
|
19
|
+
/** Override TTY detection (uses process.stdout.isTTY if not specified) */
|
|
20
|
+
isTTY?: boolean;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Gets the value of an environment variable.
|