hacksh 0.13.0 → 0.15.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/README.md +109 -89
- package/dist/command-pPKGCjNA.d.ts +389 -0
- package/dist/index.d.ts +17 -418
- package/dist/index.js +139 -1159
- package/dist/index.js.map +1 -1
- package/dist/pretty-BFub611x.js +1012 -0
- package/dist/pretty-BFub611x.js.map +1 -0
- package/dist/printer-api.d.ts +13 -0
- package/dist/printer-api.js +2 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,410 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
interface HackshIssue {
|
|
4
|
-
arg: string;
|
|
5
|
-
message: string;
|
|
6
|
-
issue?: $ZodIssue;
|
|
7
|
-
}
|
|
8
|
-
declare class HackshUsageError extends Error {
|
|
9
|
-
readonly command: AnyCommandDef;
|
|
10
|
-
constructor(message: string, command: AnyCommandDef, options?: ErrorOptions);
|
|
11
|
-
}
|
|
12
|
-
declare class HackshValidationError extends HackshUsageError {
|
|
13
|
-
readonly issues: ReadonlyArray<HackshIssue>;
|
|
14
|
-
constructor(command: AnyCommandDef, issues: ReadonlyArray<HackshIssue>);
|
|
15
|
-
}
|
|
16
|
-
type PromptKind = "select" | "confirm" | "text";
|
|
17
|
-
type HackshPromptErrorReason = "non-interactive" | "cancelled" | "aborted" | "eof" | "overlapping" | "invalid-options" | "input-error" | "printer-error";
|
|
18
|
-
interface PromptErrorDetails {
|
|
19
|
-
kind: PromptKind;
|
|
20
|
-
message: string;
|
|
21
|
-
choices?: readonly string[];
|
|
22
|
-
}
|
|
23
|
-
/** An input request that could not be completed safely. */
|
|
24
|
-
declare class HackshPromptError extends Error {
|
|
25
|
-
readonly reason: HackshPromptErrorReason;
|
|
26
|
-
readonly prompt: PromptErrorDetails;
|
|
27
|
-
constructor(reason: HackshPromptErrorReason, prompt: PromptErrorDetails, message: string, options?: ErrorOptions);
|
|
28
|
-
}
|
|
29
|
-
/** An external command that did not succeed; `result` is not enumerable so error summaries omit child output. */
|
|
30
|
-
declare class HackshExecError extends Error {
|
|
31
|
-
#private;
|
|
32
|
-
constructor(message: string, result: ExecFailure, options?: ErrorOptions);
|
|
33
|
-
get result(): ExecFailure;
|
|
34
|
-
}
|
|
35
|
-
/** A requested process exit status; `runMain` exits with it and reports only a non-empty message. */
|
|
36
|
-
declare class HackshExitError extends Error {
|
|
37
|
-
readonly exitCode: number;
|
|
38
|
-
constructor(exitCode: number, message?: string, options?: ErrorOptions);
|
|
39
|
-
}
|
|
40
|
-
type HackshErrorKind = "error" | "prompt" | "usage" | "validation" | "thrown";
|
|
41
|
-
interface ValidationIssueSummary {
|
|
42
|
-
arg: string;
|
|
43
|
-
message: string;
|
|
44
|
-
code?: string;
|
|
45
|
-
path?: readonly PropertyKey[];
|
|
46
|
-
details?: Readonly<Record<string, unknown>>;
|
|
47
|
-
}
|
|
48
|
-
interface HackshErrorSummary {
|
|
49
|
-
kind: HackshErrorKind;
|
|
50
|
-
name: string;
|
|
51
|
-
message: string;
|
|
52
|
-
stack?: string;
|
|
53
|
-
cause?: unknown;
|
|
54
|
-
issues?: readonly ValidationIssueSummary[];
|
|
55
|
-
properties?: Readonly<Record<string, unknown>>;
|
|
56
|
-
value?: unknown;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/prompts.d.ts
|
|
60
|
-
interface SelectOption<T extends string> {
|
|
61
|
-
value: T;
|
|
62
|
-
label?: string;
|
|
63
|
-
hint?: string;
|
|
64
|
-
}
|
|
65
|
-
interface SelectOptions<T extends string> {
|
|
66
|
-
message: string;
|
|
67
|
-
options: readonly SelectOption<T>[];
|
|
68
|
-
initialValue?: T;
|
|
69
|
-
}
|
|
70
|
-
interface ConfirmOptions {
|
|
71
|
-
message: string;
|
|
72
|
-
initialValue?: boolean;
|
|
73
|
-
}
|
|
74
|
-
interface TextOptions {
|
|
75
|
-
message: string;
|
|
76
|
-
placeholder?: string;
|
|
77
|
-
validate?(value: string): string | undefined;
|
|
78
|
-
}
|
|
79
|
-
interface Prompter {
|
|
80
|
-
select<const T extends string>(options: SelectOptions<T>): Promise<T>;
|
|
81
|
-
confirm(options: ConfirmOptions): Promise<boolean>;
|
|
82
|
-
text(options: TextOptions): Promise<string>;
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/logger.d.ts
|
|
86
|
-
type LogLevel = "trace" | "debug" | "info" | "warning" | "error" | "fatal";
|
|
87
|
-
type LogKind = "message" | "step" | "success";
|
|
88
|
-
type LogProperties = Record<string, unknown>;
|
|
89
|
-
/** A structured message emitted by a command's logger. */
|
|
90
|
-
interface LogRecord {
|
|
91
|
-
level: LogLevel;
|
|
92
|
-
kind: LogKind;
|
|
93
|
-
category: readonly string[];
|
|
94
|
-
message: string;
|
|
95
|
-
rawMessage: string;
|
|
96
|
-
properties: LogProperties;
|
|
97
|
-
timestamp: number;
|
|
98
|
-
}
|
|
99
|
-
interface Logger extends Prompter {
|
|
100
|
-
readonly category: readonly string[];
|
|
101
|
-
trace(message: string, properties?: LogProperties): void;
|
|
102
|
-
debug(message: string, properties?: LogProperties): void;
|
|
103
|
-
info(message: string, properties?: LogProperties): void;
|
|
104
|
-
warn(message: string, properties?: LogProperties): void;
|
|
105
|
-
error(message: string | Error, properties?: LogProperties): void;
|
|
106
|
-
fatal(message: string | Error, properties?: LogProperties): void;
|
|
107
|
-
step(message: string, properties?: LogProperties): void;
|
|
108
|
-
success(message: string, properties?: LogProperties): void;
|
|
109
|
-
with(properties: LogProperties): Logger;
|
|
110
|
-
getChild(category: string): Logger;
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/output.d.ts
|
|
114
|
-
interface OutputOptions {
|
|
115
|
-
output?: OutputPreference;
|
|
116
|
-
/** Use Unicode presentation symbols in pretty output. Defaults to true. */
|
|
117
|
-
unicode?: boolean;
|
|
118
|
-
env?: Readonly<Record<string, string | undefined>>;
|
|
119
|
-
stdin?: TerminalInput;
|
|
120
|
-
stdout?: TerminalOutput;
|
|
121
|
-
stderr?: OutputWriter;
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/usage.d.ts
|
|
125
|
-
interface UsageArgumentSummary {
|
|
126
|
-
name: string;
|
|
127
|
-
required: boolean;
|
|
128
|
-
variadic: boolean;
|
|
129
|
-
description?: string;
|
|
130
|
-
choices?: readonly string[];
|
|
131
|
-
defaultValue?: unknown;
|
|
132
|
-
}
|
|
133
|
-
interface UsageOptionSummary {
|
|
134
|
-
name: string;
|
|
135
|
-
flags: readonly string[];
|
|
136
|
-
takesValue: boolean;
|
|
137
|
-
/** Whether the long flag also accepts a `--no-` prefixed form. */
|
|
138
|
-
negatable: boolean;
|
|
139
|
-
valueName?: string;
|
|
140
|
-
required: boolean;
|
|
141
|
-
description?: string;
|
|
142
|
-
choices?: readonly string[];
|
|
143
|
-
defaultValue?: unknown;
|
|
144
|
-
env?: string;
|
|
145
|
-
}
|
|
146
|
-
interface UsageCommandSummary {
|
|
147
|
-
name: string;
|
|
148
|
-
description?: string;
|
|
149
|
-
}
|
|
150
|
-
/** A schema-free description of the useful help metadata for a command. */
|
|
151
|
-
interface UsageSummary {
|
|
152
|
-
name: string;
|
|
153
|
-
heading?: string;
|
|
154
|
-
version?: string;
|
|
155
|
-
description?: string;
|
|
156
|
-
synopsis: string;
|
|
157
|
-
arguments: readonly UsageArgumentSummary[];
|
|
158
|
-
options: readonly UsageOptionSummary[];
|
|
159
|
-
commands: readonly UsageCommandSummary[];
|
|
160
|
-
}
|
|
161
|
-
/** Build a serializable help summary without retaining command or schema objects. */
|
|
162
|
-
declare function summarizeUsage(command: AnyCommandDef): UsageSummary;
|
|
163
|
-
type UsageWriter = (text: string) => void | Promise<void>;
|
|
164
|
-
interface ShowUsageOptions extends OutputOptions {
|
|
165
|
-
write?: UsageWriter;
|
|
166
|
-
printer?: Printer;
|
|
167
|
-
stream?: PrintStream;
|
|
168
|
-
}
|
|
169
|
-
type UsageOutput = Required<Pick<ShowUsageOptions, "write">>;
|
|
170
|
-
type ShowUsageCallback = (command: AnyCommandDef, output: UsageOutput) => void | Promise<void>;
|
|
171
|
-
/** Generate usage text without writing to stdout or stderr. */
|
|
172
|
-
declare function renderUsage(command: AnyCommandDef): Promise<string>;
|
|
173
|
-
/** Generate and write usage text, awaiting asynchronous writers. */
|
|
174
|
-
declare function showUsage(command: AnyCommandDef, options?: ShowUsageOptions): Promise<void>;
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/printer.d.ts
|
|
177
|
-
type PrintStream = "stdout" | "stderr";
|
|
178
|
-
type OutputPreference = "auto" | "pretty" | "json";
|
|
179
|
-
type OutputFormat = Exclude<OutputPreference, "auto">;
|
|
180
|
-
interface OutputMode {
|
|
181
|
-
format: OutputFormat;
|
|
182
|
-
interactive: boolean;
|
|
183
|
-
color: boolean;
|
|
184
|
-
}
|
|
185
|
-
interface ResolveOutputModeOptions {
|
|
186
|
-
output?: OutputPreference;
|
|
187
|
-
env?: Readonly<Record<string, string | undefined>>;
|
|
188
|
-
inputIsTTY?: boolean;
|
|
189
|
-
outputIsTTY?: boolean;
|
|
190
|
-
}
|
|
191
|
-
/** Resolve output behavior once, before command routing or argument parsing. */
|
|
192
|
-
declare function resolveOutputMode(options?: ResolveOutputModeOptions): OutputMode;
|
|
193
|
-
interface UsagePrintEvent {
|
|
194
|
-
type: "usage";
|
|
195
|
-
usage: UsageSummary;
|
|
196
|
-
text: string;
|
|
197
|
-
stream: PrintStream;
|
|
198
|
-
}
|
|
199
|
-
interface VersionPrintEvent {
|
|
200
|
-
type: "version";
|
|
201
|
-
version: string;
|
|
202
|
-
}
|
|
203
|
-
interface ErrorPrintEvent {
|
|
204
|
-
type: "error";
|
|
205
|
-
error: HackshErrorSummary;
|
|
206
|
-
}
|
|
207
|
-
interface LogPrintEvent {
|
|
208
|
-
type: "log";
|
|
209
|
-
record: LogRecord;
|
|
210
|
-
}
|
|
211
|
-
interface PromptChoiceState {
|
|
212
|
-
value: string;
|
|
213
|
-
label: string;
|
|
214
|
-
hint?: string;
|
|
215
|
-
selected: boolean;
|
|
216
|
-
}
|
|
217
|
-
type PromptStatus = "active" | "error" | "submitted" | "closed";
|
|
218
|
-
interface PromptStateBase {
|
|
219
|
-
message: string;
|
|
220
|
-
status: PromptStatus;
|
|
221
|
-
error?: string;
|
|
222
|
-
}
|
|
223
|
-
interface SelectPromptState extends PromptStateBase {
|
|
224
|
-
kind: "select";
|
|
225
|
-
choices: readonly PromptChoiceState[];
|
|
226
|
-
value: string;
|
|
227
|
-
}
|
|
228
|
-
interface ConfirmPromptState extends PromptStateBase {
|
|
229
|
-
kind: "confirm";
|
|
230
|
-
value: boolean;
|
|
231
|
-
defaultValue?: boolean;
|
|
232
|
-
}
|
|
233
|
-
interface TextPromptState extends PromptStateBase {
|
|
234
|
-
kind: "text";
|
|
235
|
-
value: string;
|
|
236
|
-
placeholder?: string;
|
|
237
|
-
}
|
|
238
|
-
type PromptState = SelectPromptState | ConfirmPromptState | TextPromptState;
|
|
239
|
-
interface PromptPrintEvent {
|
|
240
|
-
type: "prompt";
|
|
241
|
-
prompt: PromptState;
|
|
242
|
-
}
|
|
243
|
-
interface ExecPrintEvent {
|
|
244
|
-
type: "exec";
|
|
245
|
-
phase: "start" | "skip";
|
|
246
|
-
command: Omit<ExecCommand, "cwd"> & {
|
|
247
|
-
cwd?: string;
|
|
248
|
-
};
|
|
249
|
-
stdio: {
|
|
250
|
-
stdin: "ignore" | "input" | "inherit";
|
|
251
|
-
stdout: "pipe" | "inherit";
|
|
252
|
-
stderr: "pipe" | "inherit";
|
|
253
|
-
};
|
|
254
|
-
interactive: boolean;
|
|
255
|
-
}
|
|
256
|
-
/** A semantic, command- and schema-free output value emitted by hacksh. */
|
|
257
|
-
type PrintEvent = UsagePrintEvent | VersionPrintEvent | ErrorPrintEvent | LogPrintEvent | PromptPrintEvent | ExecPrintEvent;
|
|
258
|
-
/** Receives every output event produced by one command invocation. */
|
|
259
|
-
interface Printer {
|
|
260
|
-
print(event: PrintEvent): void | Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
/** Undecorated console compatibility adapter; automatic output uses the selected format printer. */
|
|
263
|
-
declare const consolePrinter: Printer;
|
|
264
|
-
interface OutputWriter {
|
|
265
|
-
write(text: string): unknown;
|
|
266
|
-
}
|
|
267
|
-
interface TerminalInput {
|
|
268
|
-
readonly isTTY?: boolean;
|
|
269
|
-
readonly isRaw?: boolean;
|
|
270
|
-
readonly readableFlowing?: boolean | null;
|
|
271
|
-
setRawMode?(mode: boolean): unknown;
|
|
272
|
-
resume(): unknown;
|
|
273
|
-
pause(): unknown;
|
|
274
|
-
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
275
|
-
removeListener(event: string, listener: (...args: never[]) => void): unknown;
|
|
276
|
-
}
|
|
277
|
-
interface TerminalOutput extends OutputWriter {
|
|
278
|
-
readonly isTTY?: boolean;
|
|
279
|
-
readonly columns?: number;
|
|
280
|
-
}
|
|
281
|
-
interface JsonPrinterOptions {
|
|
282
|
-
stdout?: OutputWriter;
|
|
283
|
-
stderr?: OutputWriter;
|
|
284
|
-
}
|
|
285
|
-
interface StreamPrinterOptions {
|
|
286
|
-
stdout: OutputWriter;
|
|
287
|
-
stderr: OutputWriter;
|
|
288
|
-
}
|
|
289
|
-
/** Create an undecorated stream-backed compatibility adapter. */
|
|
290
|
-
declare function createStreamPrinter(options: StreamPrinterOptions): Printer;
|
|
291
|
-
/** Create a one-semantic-event-per-line JSON printer. */
|
|
292
|
-
declare function createJsonPrinter(options?: JsonPrinterOptions): Printer;
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/exec.d.ts
|
|
295
|
-
type Environment = Readonly<Record<string, string | undefined>>;
|
|
296
|
-
interface ExecOptions {
|
|
297
|
-
cwd?: string;
|
|
298
|
-
env?: Environment;
|
|
299
|
-
input?: string;
|
|
300
|
-
reject?: boolean;
|
|
301
|
-
timeout?: number;
|
|
302
|
-
signal?: AbortSignal;
|
|
303
|
-
maxBuffer?: number;
|
|
304
|
-
forceKillAfterDelay?: number;
|
|
305
|
-
stdin?: "pipe" | "inherit";
|
|
306
|
-
stdout?: "pipe" | "inherit";
|
|
307
|
-
stderr?: "pipe" | "inherit";
|
|
308
|
-
interactive?: boolean;
|
|
309
|
-
display?: boolean;
|
|
310
|
-
redact?: readonly string[];
|
|
311
|
-
dryRun?: boolean;
|
|
312
|
-
}
|
|
313
|
-
interface ExecCommand {
|
|
314
|
-
file: string;
|
|
315
|
-
args: readonly string[];
|
|
316
|
-
cwd: string | undefined;
|
|
317
|
-
}
|
|
318
|
-
interface ExecSuccess {
|
|
319
|
-
status: "succeeded";
|
|
320
|
-
command: ExecCommand;
|
|
321
|
-
stdout: string;
|
|
322
|
-
stderr: string;
|
|
323
|
-
exitCode: 0;
|
|
324
|
-
}
|
|
325
|
-
type ExecFailure = {
|
|
326
|
-
status: "failed";
|
|
327
|
-
command: ExecCommand;
|
|
328
|
-
stdout: string;
|
|
329
|
-
stderr: string;
|
|
330
|
-
} & ({
|
|
331
|
-
reason: "exit-code";
|
|
332
|
-
exitCode: number;
|
|
333
|
-
} | {
|
|
334
|
-
reason: "signal";
|
|
335
|
-
signal: string;
|
|
336
|
-
} | {
|
|
337
|
-
reason: "spawn";
|
|
338
|
-
error: Error;
|
|
339
|
-
} | {
|
|
340
|
-
reason: "timeout" | "aborted" | "output-limit";
|
|
341
|
-
} | {
|
|
342
|
-
reason: "json-output" | "non-interactive" | "overlapping";
|
|
343
|
-
});
|
|
344
|
-
type ExecFailureReason = ExecFailure["reason"];
|
|
345
|
-
type ExecResult = ExecSuccess | ExecFailure;
|
|
346
|
-
interface ExecSkipped {
|
|
347
|
-
status: "skipped";
|
|
348
|
-
command: ExecCommand;
|
|
349
|
-
}
|
|
350
|
-
type ExecOutcome<O extends ExecOptions> = "reject" extends keyof O ? false extends O["reject"] ? ExecResult : ExecSuccess : ExecSuccess;
|
|
351
|
-
type SpecifiedDryRun<O> = "dryRun" extends keyof O ? O["dryRun"] : false;
|
|
352
|
-
type ReturnsFailure<O extends ExecOptions> = "reject" extends keyof O ? false extends O["reject"] ? true : false : false;
|
|
353
|
-
type AbortedFailure = {
|
|
354
|
-
status: "failed";
|
|
355
|
-
command: ExecCommand;
|
|
356
|
-
stdout: string;
|
|
357
|
-
stderr: string;
|
|
358
|
-
reason: "aborted";
|
|
359
|
-
};
|
|
360
|
-
type DefiniteSkip<O extends ExecOptions> = ReturnsFailure<O> extends true ? ExecSkipped | AbortedFailure : ExecSkipped;
|
|
361
|
-
type ExecReturn<O extends ExecOptions> = true extends SpecifiedDryRun<O> ? false extends SpecifiedDryRun<O> ? ExecSkipped | ExecOutcome<O> : undefined extends SpecifiedDryRun<O> ? ExecSkipped | ExecOutcome<O> : DefiniteSkip<O> : ExecOutcome<O>;
|
|
362
|
-
type RejectInheritedInput<O> = O extends {
|
|
363
|
-
input: string;
|
|
364
|
-
stdin: "inherit";
|
|
365
|
-
} ? never : unknown;
|
|
366
|
-
type Exec = <const O extends ExecOptions = {}>(file: string, args?: readonly string[], options?: O & { [K in Exclude<keyof O, keyof ExecOptions>]: never; } & RejectInheritedInput<O>) => Promise<ExecReturn<O>>;
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/schema.d.ts
|
|
369
|
-
type ArgsSchema = $ZodObject;
|
|
370
|
-
type EmptyArgs = $ZodObject<{}>;
|
|
371
|
-
type ShapeOf<S extends ArgsSchema> = S["_zod"]["def"]["shape"];
|
|
372
|
-
type ArgKey<S extends ArgsSchema> = Extract<keyof ShapeOf<S>, string>;
|
|
373
|
-
type OptionKey<S extends ArgsSchema> = Exclude<ArgKey<S>, typeof POSITIONALS_KEY>;
|
|
374
|
-
declare const POSITIONALS_KEY = "_";
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region src/command.d.ts
|
|
377
|
-
interface ArgOptions {
|
|
378
|
-
alias?: string | readonly string[];
|
|
379
|
-
valueName?: string;
|
|
380
|
-
env?: string | false;
|
|
381
|
-
}
|
|
382
|
-
type ArgOptionsMap<S extends ArgsSchema> = Partial<Record<OptionKey<S>, ArgOptions>>;
|
|
383
|
-
interface CommandContext<S extends ArgsSchema> {
|
|
384
|
-
cmd: CommandDef<S>;
|
|
385
|
-
args: output<S>;
|
|
386
|
-
rawArgs: string[];
|
|
387
|
-
passthrough: string[];
|
|
388
|
-
extraArgs: string[];
|
|
389
|
-
logger: Logger;
|
|
390
|
-
exec: Exec;
|
|
391
|
-
signal: AbortSignal;
|
|
392
|
-
}
|
|
393
|
-
interface CommandDef<S extends ArgsSchema = EmptyArgs> {
|
|
394
|
-
name?: string;
|
|
395
|
-
version?: string;
|
|
396
|
-
description?: string;
|
|
397
|
-
hidden?: boolean;
|
|
398
|
-
/** Keep unknown options and excess positionals in extraArgs. Inherits from the parent; defaults to false. */
|
|
399
|
-
allowUnknownArgs?: boolean;
|
|
400
|
-
args?: S;
|
|
401
|
-
argOptions?: ArgOptionsMap<S>;
|
|
402
|
-
subCommands?: Record<string, CommandDef<ArgsSchema>>;
|
|
403
|
-
run?(context: CommandContext<S>): unknown;
|
|
404
|
-
}
|
|
405
|
-
type AnyCommandDef = CommandDef<ArgsSchema>;
|
|
406
|
-
declare function defineCommand<S extends ArgsSchema = EmptyArgs>(def: CommandDef<S>): CommandDef<S>;
|
|
407
|
-
//#endregion
|
|
1
|
+
import { D as OutputPreference, G as ShowUsageOptions, O as OutputWriter, Q as summarizeUsage, R as TerminalInput, X as renderUsage, Z as showUsage, _ as ExecReturn, a as ArgsSchema, c as SelectOption, ct as HackshIssue, d as Exec, dt as HackshUsageError, f as ExecCommand, ft as HackshValidationError, g as ExecResult, h as ExecOptions, i as defineCommand, j as Printer, l as SelectOptions, lt as HackshPromptError, m as ExecFailureReason, mt as PromptKind, n as CommandContext, o as ConfirmOptions, ot as HackshExecError, p as ExecFailure, pt as PromptErrorDetails, r as CommandDef, rt as Logger, s as Prompter, st as HackshExitError, t as AnyCommandDef, u as TextOptions, ut as HackshPromptErrorReason, v as ExecSkipped, y as ExecSuccess, z as TerminalOutput } from "./command-pPKGCjNA.js";
|
|
2
|
+
import { output } from "zod/v4/core";
|
|
408
3
|
//#region src/parser.d.ts
|
|
409
4
|
/**
|
|
410
5
|
* Parse and validate one command segment without routing, builtin handling, or output.
|
|
@@ -414,31 +9,35 @@ declare function parseArgs<S extends ArgsSchema>(command: CommandDef<S>, argv: s
|
|
|
414
9
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
415
10
|
}): Promise<output<S>>;
|
|
416
11
|
//#endregion
|
|
417
|
-
//#region src/
|
|
418
|
-
interface
|
|
419
|
-
|
|
420
|
-
|
|
12
|
+
//#region src/output.d.ts
|
|
13
|
+
interface OutputOptions {
|
|
14
|
+
output?: OutputPreference;
|
|
15
|
+
/** Use Unicode presentation symbols in pretty output. Defaults to true. */
|
|
16
|
+
unicode?: boolean;
|
|
17
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
18
|
+
stdin?: TerminalInput;
|
|
421
19
|
stdout?: TerminalOutput;
|
|
422
20
|
stderr?: OutputWriter;
|
|
423
21
|
}
|
|
424
|
-
/** Create the fixed human-readable renderer used for pretty output. */
|
|
425
|
-
declare function createPrettyPrinter(options: PrettyPrinterOptions): Printer;
|
|
426
22
|
//#endregion
|
|
427
23
|
//#region src/run.d.ts
|
|
428
24
|
interface RunCommandOptions extends OutputOptions {
|
|
429
25
|
printer?: Printer;
|
|
430
26
|
signal?: AbortSignal;
|
|
431
|
-
showUsage?: ShowUsageCallback;
|
|
432
27
|
}
|
|
433
|
-
|
|
28
|
+
type HandlerResult<C> = C extends {
|
|
29
|
+
run?: infer Handler;
|
|
30
|
+
} ? Handler extends ((...args: never[]) => infer R) ? Awaited<R> : never : never;
|
|
31
|
+
type CommandResult<C> = HandlerResult<C> | (C extends {
|
|
32
|
+
subCommands?: infer Children;
|
|
33
|
+
} ? Children extends Record<string, AnyCommandDef> ? string extends keyof Children ? unknown : CommandResult<Children[keyof Children]> : never : never);
|
|
34
|
+
declare function runCommand<C extends AnyCommandDef>(root: C, argv: string[], options?: RunCommandOptions): Promise<CommandResult<C> | undefined>;
|
|
434
35
|
interface RunMainOptions extends OutputOptions {
|
|
435
36
|
onError?: (error: unknown) => void | Promise<void>;
|
|
436
37
|
argv?: string[];
|
|
437
38
|
printer?: Printer;
|
|
438
|
-
showUsage?: ShowUsageCallback;
|
|
439
39
|
}
|
|
440
40
|
declare function runMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): Promise<void>;
|
|
441
|
-
declare function createMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): (argv?: string[]) => Promise<void>;
|
|
442
41
|
//#endregion
|
|
443
|
-
export { type
|
|
42
|
+
export { type CommandContext, type CommandDef, type ConfirmOptions, type Exec, type ExecCommand, type ExecFailure, type ExecFailureReason, type ExecOptions, type ExecResult, type ExecReturn, type ExecSkipped, type ExecSuccess, HackshExecError, HackshExitError, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type Logger, type OutputOptions, type PromptErrorDetails, type PromptKind, type Prompter, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type ShowUsageOptions, type TextOptions, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
|
|
444
43
|
//# sourceMappingURL=index.d.ts.map
|