@outfitter/cli 0.5.0 → 0.5.1
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 +1 -1
- package/dist/actions.d.ts +17 -2
- package/dist/actions.js +18 -1
- package/dist/cli.d.ts +1 -1
- package/dist/command.d.ts +1 -1
- package/dist/flags.d.ts +24 -2
- package/dist/flags.js +10 -2
- package/dist/index.d.ts +2 -2
- 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 +1 -1
- package/dist/query.js +1 -1
- package/dist/shared/@outfitter/{cli-md9347gn.d.ts → cli-7n5zmndx.d.ts} +94 -1
- package/dist/shared/@outfitter/{cli-b2zk8fb3.js → cli-pdb7znbq.js} +144 -1
- package/dist/shared/@outfitter/{cli-k0yvzn6d.d.ts → cli-z7mgapx5.d.ts} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/verbs.d.ts +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -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
1
|
import { SchemaCommandOptions } from "./shared/@outfitter/cli-n1k0d23k";
|
|
2
|
-
import {
|
|
2
|
+
import { FlagPreset } from "./shared/@outfitter/cli-7n5zmndx";
|
|
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
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createSchemaCommand
|
|
4
4
|
} from "./shared/@outfitter/cli-g0sn0r0b.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/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-7n5zmndx";
|
|
2
2
|
/**
|
|
3
3
|
* Create a CLI instance with a portable return type from this module.
|
|
4
4
|
*/
|
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-7n5zmndx";
|
|
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
1
|
import "./shared/@outfitter/cli-qz47jk6d";
|
|
2
2
|
import { ANSI, Theme, Tokens, createTheme } from "./shared/@outfitter/cli-xppg982q";
|
|
3
|
-
import { exitWithError, output } from "./shared/@outfitter/cli-
|
|
4
|
-
import { OutputMode } from "./shared/@outfitter/cli-
|
|
3
|
+
import { exitWithError, output } from "./shared/@outfitter/cli-z7mgapx5";
|
|
4
|
+
import { OutputMode } from "./shared/@outfitter/cli-7n5zmndx";
|
|
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-7n5zmndx";
|
|
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-z7mgapx5";
|
|
2
|
+
import "./shared/@outfitter/cli-7n5zmndx";
|
|
3
3
|
export { resolveVerbose, output, exitWithError };
|
package/dist/pagination.d.ts
CHANGED
package/dist/query.d.ts
CHANGED
package/dist/query.js
CHANGED
|
@@ -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
|
+
/** Unique identifier for deduplication */
|
|
144
|
+
readonly id: string;
|
|
145
|
+
/** Resolved output property name */
|
|
146
|
+
readonly key: TKey;
|
|
147
|
+
/** Commander option definition (e.g., "--force" or "--no-codemods") */
|
|
148
|
+
readonly flags: string;
|
|
149
|
+
/** Help description for the option */
|
|
150
|
+
readonly description: string;
|
|
151
|
+
/** Default resolved value (defaults to false) */
|
|
152
|
+
readonly defaultValue?: boolean;
|
|
153
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
154
|
+
readonly sources?: readonly string[];
|
|
155
|
+
/** Positive keys that should be negated (e.g., "codemods" for --no-codemods) */
|
|
156
|
+
readonly negatedSources?: readonly string[];
|
|
157
|
+
/** Whether the option is required */
|
|
158
|
+
readonly required?: boolean;
|
|
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
|
+
/** Unique identifier for deduplication */
|
|
168
|
+
readonly id: string;
|
|
169
|
+
/** Resolved output property name */
|
|
170
|
+
readonly key: TKey;
|
|
171
|
+
/** Commander option definition */
|
|
172
|
+
readonly flags: string;
|
|
173
|
+
/** Help description for the option */
|
|
174
|
+
readonly description: string;
|
|
175
|
+
/** Allowed enum values */
|
|
176
|
+
readonly values: readonly TValue[];
|
|
177
|
+
/** Fallback value when input is missing or invalid */
|
|
178
|
+
readonly defaultValue: TValue;
|
|
179
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
180
|
+
readonly sources?: readonly string[];
|
|
181
|
+
/** Whether the option is required */
|
|
182
|
+
readonly required?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for creating a custom numeric flag preset.
|
|
186
|
+
*/
|
|
187
|
+
interface NumberFlagPresetConfig<TKey extends string> {
|
|
188
|
+
/** Unique identifier for deduplication */
|
|
189
|
+
readonly id: string;
|
|
190
|
+
/** Resolved output property name */
|
|
191
|
+
readonly key: TKey;
|
|
192
|
+
/** Commander option definition */
|
|
193
|
+
readonly flags: string;
|
|
194
|
+
/** Help description for the option */
|
|
195
|
+
readonly description: string;
|
|
196
|
+
/** Fallback value when input is missing or invalid */
|
|
197
|
+
readonly defaultValue: number;
|
|
198
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
199
|
+
readonly sources?: readonly string[];
|
|
200
|
+
/** Lower bound (inclusive) */
|
|
201
|
+
readonly min?: number;
|
|
202
|
+
/** Upper bound (inclusive) */
|
|
203
|
+
readonly max?: number;
|
|
204
|
+
/** Floor parsed values (defaults to true) */
|
|
205
|
+
readonly integer?: boolean;
|
|
206
|
+
/** Whether the option is required */
|
|
207
|
+
readonly required?: boolean;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Configuration for creating a custom string-list flag preset.
|
|
211
|
+
*/
|
|
212
|
+
interface StringListFlagPresetConfig<TKey extends string> {
|
|
213
|
+
/** Unique identifier for deduplication */
|
|
214
|
+
readonly id: string;
|
|
215
|
+
/** Resolved output property name */
|
|
216
|
+
readonly key: TKey;
|
|
217
|
+
/** Commander option definition */
|
|
218
|
+
readonly flags: string;
|
|
219
|
+
/** Help description for the option */
|
|
220
|
+
readonly description: string;
|
|
221
|
+
/** Candidate raw flag keys to read (defaults to [key]) */
|
|
222
|
+
readonly sources?: readonly string[];
|
|
223
|
+
/** Fallback list when input is missing or invalid */
|
|
224
|
+
readonly defaultValue?: readonly string[];
|
|
225
|
+
/** Split string values by this separator (defaults to ",") */
|
|
226
|
+
readonly separator?: string;
|
|
227
|
+
/** Remove duplicate values while preserving order */
|
|
228
|
+
readonly dedupe?: boolean;
|
|
229
|
+
/** Whether the option is required */
|
|
230
|
+
readonly required?: boolean;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
140
233
|
* Result of composing multiple presets together.
|
|
141
234
|
* Options are deduplicated by preset id (first wins).
|
|
142
235
|
*/
|
|
@@ -392,4 +485,4 @@ interface CursorOptions {
|
|
|
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 };
|
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-7n5zmndx";
|
|
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.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -115,7 +115,8 @@
|
|
|
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
122
|
"@clack/prompts": "^0.11.0",
|
|
@@ -132,7 +133,7 @@
|
|
|
132
133
|
"devDependencies": {
|
|
133
134
|
"@outfitter/config": "0.3.2",
|
|
134
135
|
"@outfitter/contracts": "0.4.0",
|
|
135
|
-
"@outfitter/schema": "0.2.
|
|
136
|
+
"@outfitter/schema": "0.2.1",
|
|
136
137
|
"@types/bun": "^1.3.7",
|
|
137
138
|
"@types/node": "^25.0.10",
|
|
138
139
|
"typescript": "^5.9.3"
|