icore 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/terminal/app.d.ts +25 -6
- package/package.json +1 -1
package/dist/terminal/app.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* This file must not contain argv tokenization, option validation internals,
|
|
10
10
|
* domain behavior, or application-specific report mapping.
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
12
|
+
import type { CommandContext, CommandResolutionOptions, Commands, PreparedCommand } from '../command/mechanics';
|
|
13
13
|
import type { OptionsSchema } from '../options/schema';
|
|
14
14
|
import { type Presentation, type PresentationResult } from '../presentation/facade';
|
|
15
15
|
import { type PresentationFormat } from '../presentation/format-options';
|
|
@@ -21,8 +21,27 @@ import { type Output } from '../output/facade';
|
|
|
21
21
|
* or no output. Other result shapes are rejected before writing to stdout.
|
|
22
22
|
*/
|
|
23
23
|
export type TerminalCommandOutput = string | AsyncIterable<string> | PresentationResult | undefined;
|
|
24
|
-
type
|
|
25
|
-
|
|
24
|
+
type BivariantCallback<TInput, TOutput> = {
|
|
25
|
+
bivarianceHack(input: TInput): TOutput;
|
|
26
|
+
}['bivarianceHack'];
|
|
27
|
+
type TerminalCommandDefinition = {
|
|
28
|
+
path: readonly [string, ...string[]];
|
|
29
|
+
options: OptionsSchema;
|
|
30
|
+
metadata?: unknown;
|
|
31
|
+
allowExtraPositionals?: boolean;
|
|
32
|
+
prepare?: BivariantCallback<PreparedCommandInput, unknown | Promise<unknown>>;
|
|
33
|
+
handle: BivariantCallback<TerminalCommandInput, TerminalCommandOutput | Promise<TerminalCommandOutput>>;
|
|
34
|
+
};
|
|
35
|
+
type PreparedCommandInput = {
|
|
36
|
+
options: Record<string, unknown>;
|
|
37
|
+
provided: Record<string, boolean>;
|
|
38
|
+
positionals: string[];
|
|
39
|
+
};
|
|
40
|
+
type TerminalCommandInput = PreparedCommandInput & {
|
|
41
|
+
context: unknown;
|
|
42
|
+
payload?: unknown;
|
|
43
|
+
};
|
|
44
|
+
export type TerminalAppOptions<TCommands extends readonly TerminalCommandDefinition[]> = {
|
|
26
45
|
commands: Commands<TCommands>;
|
|
27
46
|
/** Custom presentation facade. */
|
|
28
47
|
presentation?: Presentation;
|
|
@@ -31,14 +50,14 @@ export type TerminalAppOptions<TContext, TCommands extends readonly TerminalComm
|
|
|
31
50
|
/** Resolves output format. */
|
|
32
51
|
resolveFormat?(prepared: PreparedCommand<TCommands[number]>): PresentationFormat | undefined;
|
|
33
52
|
};
|
|
34
|
-
export type TerminalApp<
|
|
53
|
+
export type TerminalApp<TCommands extends readonly TerminalCommandDefinition[]> = {
|
|
35
54
|
commands: Commands<TCommands>;
|
|
36
55
|
presentation: Presentation;
|
|
37
56
|
output: Output;
|
|
38
57
|
/** No application context required. */
|
|
39
58
|
prepare(args: readonly string[], options?: CommandResolutionOptions): Promise<PreparedCommand<TCommands[number]>>;
|
|
40
59
|
/** Returns a process-style exit code. */
|
|
41
|
-
run(args: readonly string[], context:
|
|
60
|
+
run(args: readonly string[], context: CommandContext<TCommands[number]>, options?: CommandResolutionOptions): Promise<number>;
|
|
42
61
|
};
|
|
43
62
|
/**
|
|
44
63
|
* Composes command mechanics, presentation rendering, and output delivery into
|
|
@@ -47,5 +66,5 @@ export type TerminalApp<TContext, TCommands extends readonly TerminalCommandDefi
|
|
|
47
66
|
* Command handlers keep ownership of application work; this facade only
|
|
48
67
|
* prepares commands, renders supported terminal results, and writes output.
|
|
49
68
|
*/
|
|
50
|
-
export declare function createTerminalApp<
|
|
69
|
+
export declare function createTerminalApp<const TCommands extends readonly TerminalCommandDefinition[]>(options: TerminalAppOptions<TCommands>): TerminalApp<TCommands>;
|
|
51
70
|
export {};
|