@@ -16,8 +16,9 @@ import type { runProgram } from 'universe/util';
1616 * `unknown` for unrecognized arguments.
1717 */
1818export type Arguments <
19- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
20- > = _Arguments < FrameworkArguments & CustomCliArguments > ;
19+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
20+ CustomExecutionContext extends ExecutionContext = ExecutionContext
21+ > = _Arguments < FrameworkArguments < CustomExecutionContext > & CustomCliArguments > ;
2122
2223/**
2324 * Represents an empty or "null" `Arguments` object devoid of useful data.
@@ -26,10 +27,12 @@ export type Arguments<
2627 * various `Arguments`-returning functions when an exceptional event prevents
2728 * yargs from returning a real `Arguments` parse result.
2829 */
29- export type NullArguments = {
30+ export type NullArguments <
31+ CustomExecutionContext extends ExecutionContext = ExecutionContext
32+ > = {
3033 $0 : '<NullArguments: no parse result available due to exception>' ;
3134 _ : [ ] ;
32- } & FrameworkArguments ;
35+ } & FrameworkArguments < CustomExecutionContext > ;
3336
3437/**
3538 * Represents a pre-configured yargs instance ready for argument parsing and
@@ -39,9 +42,10 @@ export type NullArguments = {
3942 * by yargs but with several differences and should be preferred.
4043 */
4144export type Program <
42- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
45+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
46+ CustomExecutionContext extends ExecutionContext = ExecutionContext
4347> = Omit <
44- _Program < FrameworkArguments & CustomCliArguments > ,
48+ _Program < FrameworkArguments < CustomExecutionContext > & CustomCliArguments > ,
4549 | 'command'
4650 | 'onFinishCommand'
4751 | 'showHelpOnFail'
@@ -64,15 +68,18 @@ export type Program<
6468 command : {
6569 (
6670 command : string [ ] ,
67- description : Configuration < CustomCliArguments > [ 'description' ] ,
71+ description : Configuration <
72+ CustomCliArguments ,
73+ CustomExecutionContext
74+ > [ 'description' ] ,
6875 builder :
6976 | ( ( yargs : _Program , helpOrVersionSet : boolean ) => _Program )
7077 | Record < string , never > ,
71- handler : Configuration < CustomCliArguments > [ 'handler' ] ,
78+ handler : Configuration < CustomCliArguments , CustomExecutionContext > [ 'handler' ] ,
7279 // ? configureArguments already handles this use case, so...
7380 middlewares : [ ] ,
74- deprecated : Configuration < CustomCliArguments > [ 'deprecated' ]
75- ) : Program < CustomCliArguments > ;
81+ deprecated : Configuration < CustomCliArguments , CustomExecutionContext > [ 'deprecated' ]
82+ ) : Program < CustomCliArguments , CustomExecutionContext > ;
7683 } ;
7784
7885 /**
@@ -86,7 +93,9 @@ export type Program<
8693 *
8794 * @see {@link _Program.showHelpOnFail }
8895 */
89- showHelpOnFail : ( enabled : boolean ) => Program < CustomCliArguments > ;
96+ showHelpOnFail : (
97+ enabled : boolean
98+ ) => Program < CustomCliArguments , CustomExecutionContext > ;
9099
91100 /**
92101 * Identical to `yargs::command` except its execution is enqueued and
@@ -95,7 +104,7 @@ export type Program<
95104 * @see {@link _Program.command }
96105 * @internal
97106 */
98- command_deferred : Program < CustomCliArguments > [ 'command' ] ;
107+ command_deferred : Program < CustomCliArguments , CustomExecutionContext > [ 'command' ] ;
99108
100109 /**
101110 * @see {@link Program.command_deferred }
@@ -108,22 +117,31 @@ export type Program<
108117 * Represents an "effector" {@link Program} instance.
109118 */
110119export type EffectorProgram <
111- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
112- > = Omit < Program < CustomCliArguments > , 'command_deferred' | 'command_finalize_deferred' > ;
120+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
121+ CustomExecutionContext extends ExecutionContext = ExecutionContext
122+ > = Omit <
123+ Program < CustomCliArguments , CustomExecutionContext > ,
124+ 'command_deferred' | 'command_finalize_deferred'
125+ > ;
113126
114127/**
115128 * Represents an "helper" {@link Program} instance.
116129 */
117130export type HelperProgram <
118- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
119- > = Omit < Program < CustomCliArguments > , 'demand' | 'demandCommand' | 'command' > ;
131+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
132+ CustomExecutionContext extends ExecutionContext = ExecutionContext
133+ > = Omit <
134+ Program < CustomCliArguments , CustomExecutionContext > ,
135+ 'demand' | 'demandCommand' | 'command'
136+ > ;
120137
121138/**
122139 * Represents an "router" {@link Program} instance.
123140 */
124141export type RouterProgram <
125- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
126- > = Pick < Program < CustomCliArguments > , 'parseAsync' | 'command' > ;
142+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
143+ CustomExecutionContext extends ExecutionContext = ExecutionContext
144+ > = Pick < Program < CustomCliArguments , CustomExecutionContext > , 'parseAsync' | 'command' > ;
127145
128146/**
129147 * Represents valid {@link Configuration} module types that can be loaded.
@@ -140,21 +158,27 @@ export type ProgramDescriptor = 'effector' | 'helper' | 'router';
140158 */
141159export type DescriptorToProgram <
142160 Descriptor extends ProgramDescriptor ,
143- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
161+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
162+ CustomExecutionContext extends ExecutionContext = ExecutionContext
144163> = 'effector' extends Descriptor
145- ? EffectorProgram < CustomCliArguments >
164+ ? EffectorProgram < CustomCliArguments , CustomExecutionContext >
146165 : 'helper' extends Descriptor
147- ? HelperProgram < CustomCliArguments >
148- : RouterProgram < CustomCliArguments > ;
166+ ? HelperProgram < CustomCliArguments , CustomExecutionContext >
167+ : RouterProgram < CustomCliArguments , CustomExecutionContext > ;
149168
150169/**
151170 * Represents the program types that represent every Black Flag command as
152171 * aptly-named values in an object.
153172 */
154173export type Programs <
155- CustomCliArguments extends Record < string , unknown > = Record < string , unknown >
174+ CustomCliArguments extends Record < string , unknown > = Record < string , unknown > ,
175+ CustomExecutionContext extends ExecutionContext = ExecutionContext
156176> = {
157- [ Descriptor in ProgramDescriptor ] : DescriptorToProgram < Descriptor , CustomCliArguments > ;
177+ [ Descriptor in ProgramDescriptor ] : DescriptorToProgram <
178+ Descriptor ,
179+ CustomCliArguments ,
180+ CustomExecutionContext
181+ > ;
158182} ;
159183
160184/**
@@ -230,8 +254,10 @@ export type ProgramMetadata = {
230254 * (e.g. `Arguments<MyCustomArgs>`), which will extend `FrameworkArguments` for
231255 * you.
232256 */
233- export type FrameworkArguments = {
234- [ $executionContext ] : ExecutionContext ;
257+ export type FrameworkArguments <
258+ CustomExecutionContext extends ExecutionContext = ExecutionContext
259+ > = {
260+ [ $executionContext ] : CustomExecutionContext ;
235261} ;
236262
237263/**
0 commit comments