@optique/config 1.0.0-dev.429 → 1.0.0-dev.432

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/run.d.cts DELETED
@@ -1,323 +0,0 @@
1
- import { ConfigContext, ConfigMeta } from "./index-BZLEbR0f.cjs";
2
- import { Parser } from "@optique/core/parser";
3
- import { RunOptions } from "@optique/core/facade";
4
-
5
- //#region src/run.d.ts
6
-
7
- /**
8
- * Options for single-file config loading.
9
- *
10
- * @template TValue The parser value type, inferred from the parser.
11
- * @template THelp The return type when help is shown.
12
- * @template TError The return type when an error occurs.
13
- * @since 0.10.0
14
- */
15
- interface SingleFileOptions<TValue, THelp = void, TError = never> {
16
- /**
17
- * Function to extract the config file path from parsed CLI arguments.
18
- * This function receives the result of the first parse pass and should
19
- * return the config file path or undefined if no config file is specified.
20
- *
21
- * The `parsed` parameter is typed based on the parser's result type,
22
- * providing full type safety without manual type assertions.
23
- */
24
- readonly getConfigPath: (parsed: TValue) => string | undefined;
25
- /**
26
- * Custom parser function for reading config file contents.
27
- * If not provided, defaults to JSON.parse.
28
- *
29
- * @param contents The raw file contents as Uint8Array.
30
- * @returns The parsed config data (will be validated by schema).
31
- */
32
- readonly fileParser?: (contents: Uint8Array) => unknown;
33
- /**
34
- * Command-line arguments to parse.
35
- * If not provided, defaults to an empty array.
36
- */
37
- readonly args?: readonly string[];
38
- /**
39
- * Name of the program for help/error output.
40
- * If not provided, inferred from process.argv[1].
41
- */
42
- readonly programName?: string;
43
- /**
44
- * Help configuration. See RunOptions for details.
45
- */
46
- readonly help?: RunOptions<THelp, TError>["help"];
47
- /**
48
- * Version configuration. See RunOptions for details.
49
- */
50
- readonly version?: RunOptions<THelp, TError>["version"];
51
- /**
52
- * Completion configuration. See RunOptions for details.
53
- */
54
- readonly completion?: RunOptions<THelp, TError>["completion"];
55
- /**
56
- * Output function for standard output. See RunOptions for details.
57
- */
58
- readonly stdout?: RunOptions<THelp, TError>["stdout"];
59
- /**
60
- * Output function for standard error. See RunOptions for details.
61
- */
62
- readonly stderr?: RunOptions<THelp, TError>["stderr"];
63
- /**
64
- * Whether to enable colored output. See RunOptions for details.
65
- */
66
- readonly colors?: RunOptions<THelp, TError>["colors"];
67
- /**
68
- * Maximum width for output formatting. See RunOptions for details.
69
- */
70
- readonly maxWidth?: RunOptions<THelp, TError>["maxWidth"];
71
- /**
72
- * Whether and how to display default values. See RunOptions for details.
73
- */
74
- readonly showDefault?: RunOptions<THelp, TError>["showDefault"];
75
- /**
76
- * Whether and how to display valid choices. See RunOptions for details.
77
- */
78
- readonly showChoices?: RunOptions<THelp, TError>["showChoices"];
79
- /**
80
- * What to display above error messages. See RunOptions for details.
81
- */
82
- readonly aboveError?: RunOptions<THelp, TError>["aboveError"];
83
- /**
84
- * Brief description for help text. See RunOptions for details.
85
- */
86
- readonly brief?: RunOptions<THelp, TError>["brief"];
87
- /**
88
- * Detailed description for help text. See RunOptions for details.
89
- */
90
- readonly description?: RunOptions<THelp, TError>["description"];
91
- /**
92
- * Usage examples for help text. See RunOptions for details.
93
- */
94
- readonly examples?: RunOptions<THelp, TError>["examples"];
95
- /**
96
- * Author information for help text. See RunOptions for details.
97
- */
98
- readonly author?: RunOptions<THelp, TError>["author"];
99
- /**
100
- * Bug reporting information for help text. See RunOptions for details.
101
- */
102
- readonly bugs?: RunOptions<THelp, TError>["bugs"];
103
- /**
104
- * Footer text for help. See RunOptions for details.
105
- */
106
- readonly footer?: RunOptions<THelp, TError>["footer"];
107
- /**
108
- * Error handler. See RunOptions for details.
109
- */
110
- readonly onError?: RunOptions<THelp, TError>["onError"];
111
- }
112
- /**
113
- * Result type for custom config loading.
114
- *
115
- * @template TConfigMeta Metadata type associated with loaded config data.
116
- * @since 1.0.0
117
- */
118
- interface ConfigLoadResult<TConfigMeta = ConfigMeta> {
119
- /**
120
- * Raw config data to validate against the schema.
121
- */
122
- readonly config: unknown;
123
- /**
124
- * Metadata about where the config came from.
125
- */
126
- readonly meta: TConfigMeta;
127
- }
128
- /**
129
- * Options for custom config loading with multi-file merging support.
130
- *
131
- * @template TValue The parser value type, inferred from the parser.
132
- * @template THelp The return type when help is shown.
133
- * @template TError The return type when an error occurs.
134
- * @since 0.10.0
135
- */
136
- interface CustomLoadOptions<TValue, TConfigMeta = ConfigMeta, THelp = void, TError = never> {
137
- /**
138
- * Custom loader function that receives the first-pass parse result and
139
- * returns the config data (or a Promise of it). This allows full control
140
- * over file discovery, loading, merging, and error handling.
141
- *
142
- * The returned data will be validated against the schema.
143
- *
144
- * @param parsed The result from the first parse pass.
145
- * @returns Config data and metadata (config is validated by schema).
146
- */
147
- readonly load: (parsed: TValue) => Promise<ConfigLoadResult<TConfigMeta>> | ConfigLoadResult<TConfigMeta>;
148
- /**
149
- * Command-line arguments to parse.
150
- * If not provided, defaults to an empty array.
151
- */
152
- readonly args?: readonly string[];
153
- /**
154
- * Name of the program for help/error output.
155
- * If not provided, inferred from process.argv[1].
156
- */
157
- readonly programName?: string;
158
- /**
159
- * Help configuration. See RunOptions for details.
160
- */
161
- readonly help?: RunOptions<THelp, TError>["help"];
162
- /**
163
- * Version configuration. See RunOptions for details.
164
- */
165
- readonly version?: RunOptions<THelp, TError>["version"];
166
- /**
167
- * Completion configuration. See RunOptions for details.
168
- */
169
- readonly completion?: RunOptions<THelp, TError>["completion"];
170
- /**
171
- * Output function for standard output. See RunOptions for details.
172
- */
173
- readonly stdout?: RunOptions<THelp, TError>["stdout"];
174
- /**
175
- * Output function for standard error. See RunOptions for details.
176
- */
177
- readonly stderr?: RunOptions<THelp, TError>["stderr"];
178
- /**
179
- * Whether to enable colored output. See RunOptions for details.
180
- */
181
- readonly colors?: RunOptions<THelp, TError>["colors"];
182
- /**
183
- * Maximum width for output formatting. See RunOptions for details.
184
- */
185
- readonly maxWidth?: RunOptions<THelp, TError>["maxWidth"];
186
- /**
187
- * Whether and how to display default values. See RunOptions for details.
188
- */
189
- readonly showDefault?: RunOptions<THelp, TError>["showDefault"];
190
- /**
191
- * Whether and how to display valid choices. See RunOptions for details.
192
- */
193
- readonly showChoices?: RunOptions<THelp, TError>["showChoices"];
194
- /**
195
- * What to display above error messages. See RunOptions for details.
196
- */
197
- readonly aboveError?: RunOptions<THelp, TError>["aboveError"];
198
- /**
199
- * Brief description for help text. See RunOptions for details.
200
- */
201
- readonly brief?: RunOptions<THelp, TError>["brief"];
202
- /**
203
- * Detailed description for help text. See RunOptions for details.
204
- */
205
- readonly description?: RunOptions<THelp, TError>["description"];
206
- /**
207
- * Usage examples for help text. See RunOptions for details.
208
- */
209
- readonly examples?: RunOptions<THelp, TError>["examples"];
210
- /**
211
- * Author information for help text. See RunOptions for details.
212
- */
213
- readonly author?: RunOptions<THelp, TError>["author"];
214
- /**
215
- * Bug reporting information for help text. See RunOptions for details.
216
- */
217
- readonly bugs?: RunOptions<THelp, TError>["bugs"];
218
- /**
219
- * Footer text for help. See RunOptions for details.
220
- */
221
- readonly footer?: RunOptions<THelp, TError>["footer"];
222
- /**
223
- * Error handler. See RunOptions for details.
224
- */
225
- readonly onError?: RunOptions<THelp, TError>["onError"];
226
- }
227
- /**
228
- * Options for runWithConfig.
229
- *
230
- * @template TValue The parser value type, inferred from the parser.
231
- * @template THelp The return type when help is shown.
232
- * @template TError The return type when an error occurs.
233
- * @since 0.10.0
234
- */
235
- type RunWithConfigOptions<TValue, TConfigMeta = ConfigMeta, THelp = void, TError = never> = SingleFileOptions<TValue, THelp, TError> | CustomLoadOptions<TValue, TConfigMeta, THelp, TError>;
236
- /**
237
- * Runs a parser with configuration file support using two-pass parsing.
238
- *
239
- * This function performs the following steps:
240
- * 1. First pass: Parse arguments to extract config path or data
241
- * 2. Load and validate: Load config file(s) and validate using Standard Schema
242
- * 3. Second pass: Parse arguments again with config data as annotations
243
- *
244
- * The priority order for values is: CLI > config file > default.
245
- *
246
- * The function also supports help, version, and completion features. When these
247
- * special commands are detected, config loading is skipped entirely, ensuring
248
- * these features work even when config files don't exist.
249
- *
250
- * @template M The parser mode (sync or async).
251
- * @template TValue The parser value type.
252
- * @template TState The parser state type.
253
- * @template T The config data type.
254
- * @template TConfigMeta The config metadata type.
255
- * @template THelp The return type when help is shown.
256
- * @template TError The return type when an error occurs.
257
- * @param parser The parser to execute.
258
- * @param context The config context with schema.
259
- * @param options Run options - either SingleFileOptions or CustomLoadOptions.
260
- * @returns Promise that resolves to the parsed result.
261
- * @throws Error if config file validation fails.
262
- * @since 0.10.0
263
- *
264
- * @example Single file mode
265
- * ```typescript
266
- * import { z } from "zod";
267
- * import { runWithConfig } from "@optique/config/run";
268
- * import { createConfigContext, bindConfig } from "@optique/config";
269
- *
270
- * const schema = z.object({
271
- * host: z.string(),
272
- * port: z.number(),
273
- * });
274
- *
275
- * const context = createConfigContext({ schema });
276
- *
277
- * const parser = object({
278
- * config: option("--config", string()),
279
- * host: bindConfig(option("--host", string()), {
280
- * context,
281
- * key: "host",
282
- * default: "localhost",
283
- * }),
284
- * });
285
- *
286
- * const result = await runWithConfig(parser, context, {
287
- * getConfigPath: (parsed) => parsed.config,
288
- * args: process.argv.slice(2),
289
- * help: { mode: "option", onShow: () => process.exit(0) },
290
- * version: { value: "1.0.0", onShow: () => process.exit(0) },
291
- * });
292
- * ```
293
- *
294
- * @example Custom load mode (multi-file merging)
295
- * ```typescript
296
- * import { deepMerge } from "es-toolkit";
297
- *
298
- * const result = await runWithConfig(parser, context, {
299
- * load: async (parsed) => {
300
- * const configs = await Promise.all([
301
- * loadToml("/etc/app/config.toml").catch(() => ({})),
302
- * loadToml("~/.config/app/config.toml").catch(() => ({})),
303
- * loadToml("./.app.toml").catch(() => ({})),
304
- * ]);
305
- *
306
- * const configPath = parsed.config ?? "./.app.toml";
307
- * return {
308
- * config: deepMerge(...configs),
309
- * meta: {
310
- * configPath,
311
- * configDir: configPath.slice(0, configPath.lastIndexOf("/")),
312
- * },
313
- * };
314
- * },
315
- * args: process.argv.slice(2),
316
- * help: { mode: "option", onShow: () => process.exit(0) },
317
- * });
318
- * ```
319
- */
320
- declare function runWithConfig<M extends "sync" | "async", TValue, TState, T, THelp = void, TError = never>(parser: Parser<M, TValue, TState>, context: ConfigContext<T, ConfigMeta>, options: SingleFileOptions<TValue, THelp, TError>): Promise<TValue>;
321
- declare function runWithConfig<M extends "sync" | "async", TValue, TState, T, TConfigMeta = ConfigMeta, THelp = void, TError = never>(parser: Parser<M, TValue, TState>, context: ConfigContext<T, TConfigMeta>, options: CustomLoadOptions<TValue, TConfigMeta, THelp, TError>): Promise<TValue>;
322
- //#endregion
323
- export { ConfigLoadResult, CustomLoadOptions, RunWithConfigOptions, SingleFileOptions, runWithConfig };
package/dist/run.d.ts DELETED
@@ -1,323 +0,0 @@
1
- import { ConfigContext, ConfigMeta } from "./index-0XaZnIP1.js";
2
- import { RunOptions } from "@optique/core/facade";
3
- import { Parser } from "@optique/core/parser";
4
-
5
- //#region src/run.d.ts
6
-
7
- /**
8
- * Options for single-file config loading.
9
- *
10
- * @template TValue The parser value type, inferred from the parser.
11
- * @template THelp The return type when help is shown.
12
- * @template TError The return type when an error occurs.
13
- * @since 0.10.0
14
- */
15
- interface SingleFileOptions<TValue, THelp = void, TError = never> {
16
- /**
17
- * Function to extract the config file path from parsed CLI arguments.
18
- * This function receives the result of the first parse pass and should
19
- * return the config file path or undefined if no config file is specified.
20
- *
21
- * The `parsed` parameter is typed based on the parser's result type,
22
- * providing full type safety without manual type assertions.
23
- */
24
- readonly getConfigPath: (parsed: TValue) => string | undefined;
25
- /**
26
- * Custom parser function for reading config file contents.
27
- * If not provided, defaults to JSON.parse.
28
- *
29
- * @param contents The raw file contents as Uint8Array.
30
- * @returns The parsed config data (will be validated by schema).
31
- */
32
- readonly fileParser?: (contents: Uint8Array) => unknown;
33
- /**
34
- * Command-line arguments to parse.
35
- * If not provided, defaults to an empty array.
36
- */
37
- readonly args?: readonly string[];
38
- /**
39
- * Name of the program for help/error output.
40
- * If not provided, inferred from process.argv[1].
41
- */
42
- readonly programName?: string;
43
- /**
44
- * Help configuration. See RunOptions for details.
45
- */
46
- readonly help?: RunOptions<THelp, TError>["help"];
47
- /**
48
- * Version configuration. See RunOptions for details.
49
- */
50
- readonly version?: RunOptions<THelp, TError>["version"];
51
- /**
52
- * Completion configuration. See RunOptions for details.
53
- */
54
- readonly completion?: RunOptions<THelp, TError>["completion"];
55
- /**
56
- * Output function for standard output. See RunOptions for details.
57
- */
58
- readonly stdout?: RunOptions<THelp, TError>["stdout"];
59
- /**
60
- * Output function for standard error. See RunOptions for details.
61
- */
62
- readonly stderr?: RunOptions<THelp, TError>["stderr"];
63
- /**
64
- * Whether to enable colored output. See RunOptions for details.
65
- */
66
- readonly colors?: RunOptions<THelp, TError>["colors"];
67
- /**
68
- * Maximum width for output formatting. See RunOptions for details.
69
- */
70
- readonly maxWidth?: RunOptions<THelp, TError>["maxWidth"];
71
- /**
72
- * Whether and how to display default values. See RunOptions for details.
73
- */
74
- readonly showDefault?: RunOptions<THelp, TError>["showDefault"];
75
- /**
76
- * Whether and how to display valid choices. See RunOptions for details.
77
- */
78
- readonly showChoices?: RunOptions<THelp, TError>["showChoices"];
79
- /**
80
- * What to display above error messages. See RunOptions for details.
81
- */
82
- readonly aboveError?: RunOptions<THelp, TError>["aboveError"];
83
- /**
84
- * Brief description for help text. See RunOptions for details.
85
- */
86
- readonly brief?: RunOptions<THelp, TError>["brief"];
87
- /**
88
- * Detailed description for help text. See RunOptions for details.
89
- */
90
- readonly description?: RunOptions<THelp, TError>["description"];
91
- /**
92
- * Usage examples for help text. See RunOptions for details.
93
- */
94
- readonly examples?: RunOptions<THelp, TError>["examples"];
95
- /**
96
- * Author information for help text. See RunOptions for details.
97
- */
98
- readonly author?: RunOptions<THelp, TError>["author"];
99
- /**
100
- * Bug reporting information for help text. See RunOptions for details.
101
- */
102
- readonly bugs?: RunOptions<THelp, TError>["bugs"];
103
- /**
104
- * Footer text for help. See RunOptions for details.
105
- */
106
- readonly footer?: RunOptions<THelp, TError>["footer"];
107
- /**
108
- * Error handler. See RunOptions for details.
109
- */
110
- readonly onError?: RunOptions<THelp, TError>["onError"];
111
- }
112
- /**
113
- * Result type for custom config loading.
114
- *
115
- * @template TConfigMeta Metadata type associated with loaded config data.
116
- * @since 1.0.0
117
- */
118
- interface ConfigLoadResult<TConfigMeta = ConfigMeta> {
119
- /**
120
- * Raw config data to validate against the schema.
121
- */
122
- readonly config: unknown;
123
- /**
124
- * Metadata about where the config came from.
125
- */
126
- readonly meta: TConfigMeta;
127
- }
128
- /**
129
- * Options for custom config loading with multi-file merging support.
130
- *
131
- * @template TValue The parser value type, inferred from the parser.
132
- * @template THelp The return type when help is shown.
133
- * @template TError The return type when an error occurs.
134
- * @since 0.10.0
135
- */
136
- interface CustomLoadOptions<TValue, TConfigMeta = ConfigMeta, THelp = void, TError = never> {
137
- /**
138
- * Custom loader function that receives the first-pass parse result and
139
- * returns the config data (or a Promise of it). This allows full control
140
- * over file discovery, loading, merging, and error handling.
141
- *
142
- * The returned data will be validated against the schema.
143
- *
144
- * @param parsed The result from the first parse pass.
145
- * @returns Config data and metadata (config is validated by schema).
146
- */
147
- readonly load: (parsed: TValue) => Promise<ConfigLoadResult<TConfigMeta>> | ConfigLoadResult<TConfigMeta>;
148
- /**
149
- * Command-line arguments to parse.
150
- * If not provided, defaults to an empty array.
151
- */
152
- readonly args?: readonly string[];
153
- /**
154
- * Name of the program for help/error output.
155
- * If not provided, inferred from process.argv[1].
156
- */
157
- readonly programName?: string;
158
- /**
159
- * Help configuration. See RunOptions for details.
160
- */
161
- readonly help?: RunOptions<THelp, TError>["help"];
162
- /**
163
- * Version configuration. See RunOptions for details.
164
- */
165
- readonly version?: RunOptions<THelp, TError>["version"];
166
- /**
167
- * Completion configuration. See RunOptions for details.
168
- */
169
- readonly completion?: RunOptions<THelp, TError>["completion"];
170
- /**
171
- * Output function for standard output. See RunOptions for details.
172
- */
173
- readonly stdout?: RunOptions<THelp, TError>["stdout"];
174
- /**
175
- * Output function for standard error. See RunOptions for details.
176
- */
177
- readonly stderr?: RunOptions<THelp, TError>["stderr"];
178
- /**
179
- * Whether to enable colored output. See RunOptions for details.
180
- */
181
- readonly colors?: RunOptions<THelp, TError>["colors"];
182
- /**
183
- * Maximum width for output formatting. See RunOptions for details.
184
- */
185
- readonly maxWidth?: RunOptions<THelp, TError>["maxWidth"];
186
- /**
187
- * Whether and how to display default values. See RunOptions for details.
188
- */
189
- readonly showDefault?: RunOptions<THelp, TError>["showDefault"];
190
- /**
191
- * Whether and how to display valid choices. See RunOptions for details.
192
- */
193
- readonly showChoices?: RunOptions<THelp, TError>["showChoices"];
194
- /**
195
- * What to display above error messages. See RunOptions for details.
196
- */
197
- readonly aboveError?: RunOptions<THelp, TError>["aboveError"];
198
- /**
199
- * Brief description for help text. See RunOptions for details.
200
- */
201
- readonly brief?: RunOptions<THelp, TError>["brief"];
202
- /**
203
- * Detailed description for help text. See RunOptions for details.
204
- */
205
- readonly description?: RunOptions<THelp, TError>["description"];
206
- /**
207
- * Usage examples for help text. See RunOptions for details.
208
- */
209
- readonly examples?: RunOptions<THelp, TError>["examples"];
210
- /**
211
- * Author information for help text. See RunOptions for details.
212
- */
213
- readonly author?: RunOptions<THelp, TError>["author"];
214
- /**
215
- * Bug reporting information for help text. See RunOptions for details.
216
- */
217
- readonly bugs?: RunOptions<THelp, TError>["bugs"];
218
- /**
219
- * Footer text for help. See RunOptions for details.
220
- */
221
- readonly footer?: RunOptions<THelp, TError>["footer"];
222
- /**
223
- * Error handler. See RunOptions for details.
224
- */
225
- readonly onError?: RunOptions<THelp, TError>["onError"];
226
- }
227
- /**
228
- * Options for runWithConfig.
229
- *
230
- * @template TValue The parser value type, inferred from the parser.
231
- * @template THelp The return type when help is shown.
232
- * @template TError The return type when an error occurs.
233
- * @since 0.10.0
234
- */
235
- type RunWithConfigOptions<TValue, TConfigMeta = ConfigMeta, THelp = void, TError = never> = SingleFileOptions<TValue, THelp, TError> | CustomLoadOptions<TValue, TConfigMeta, THelp, TError>;
236
- /**
237
- * Runs a parser with configuration file support using two-pass parsing.
238
- *
239
- * This function performs the following steps:
240
- * 1. First pass: Parse arguments to extract config path or data
241
- * 2. Load and validate: Load config file(s) and validate using Standard Schema
242
- * 3. Second pass: Parse arguments again with config data as annotations
243
- *
244
- * The priority order for values is: CLI > config file > default.
245
- *
246
- * The function also supports help, version, and completion features. When these
247
- * special commands are detected, config loading is skipped entirely, ensuring
248
- * these features work even when config files don't exist.
249
- *
250
- * @template M The parser mode (sync or async).
251
- * @template TValue The parser value type.
252
- * @template TState The parser state type.
253
- * @template T The config data type.
254
- * @template TConfigMeta The config metadata type.
255
- * @template THelp The return type when help is shown.
256
- * @template TError The return type when an error occurs.
257
- * @param parser The parser to execute.
258
- * @param context The config context with schema.
259
- * @param options Run options - either SingleFileOptions or CustomLoadOptions.
260
- * @returns Promise that resolves to the parsed result.
261
- * @throws Error if config file validation fails.
262
- * @since 0.10.0
263
- *
264
- * @example Single file mode
265
- * ```typescript
266
- * import { z } from "zod";
267
- * import { runWithConfig } from "@optique/config/run";
268
- * import { createConfigContext, bindConfig } from "@optique/config";
269
- *
270
- * const schema = z.object({
271
- * host: z.string(),
272
- * port: z.number(),
273
- * });
274
- *
275
- * const context = createConfigContext({ schema });
276
- *
277
- * const parser = object({
278
- * config: option("--config", string()),
279
- * host: bindConfig(option("--host", string()), {
280
- * context,
281
- * key: "host",
282
- * default: "localhost",
283
- * }),
284
- * });
285
- *
286
- * const result = await runWithConfig(parser, context, {
287
- * getConfigPath: (parsed) => parsed.config,
288
- * args: process.argv.slice(2),
289
- * help: { mode: "option", onShow: () => process.exit(0) },
290
- * version: { value: "1.0.0", onShow: () => process.exit(0) },
291
- * });
292
- * ```
293
- *
294
- * @example Custom load mode (multi-file merging)
295
- * ```typescript
296
- * import { deepMerge } from "es-toolkit";
297
- *
298
- * const result = await runWithConfig(parser, context, {
299
- * load: async (parsed) => {
300
- * const configs = await Promise.all([
301
- * loadToml("/etc/app/config.toml").catch(() => ({})),
302
- * loadToml("~/.config/app/config.toml").catch(() => ({})),
303
- * loadToml("./.app.toml").catch(() => ({})),
304
- * ]);
305
- *
306
- * const configPath = parsed.config ?? "./.app.toml";
307
- * return {
308
- * config: deepMerge(...configs),
309
- * meta: {
310
- * configPath,
311
- * configDir: configPath.slice(0, configPath.lastIndexOf("/")),
312
- * },
313
- * };
314
- * },
315
- * args: process.argv.slice(2),
316
- * help: { mode: "option", onShow: () => process.exit(0) },
317
- * });
318
- * ```
319
- */
320
- declare function runWithConfig<M extends "sync" | "async", TValue, TState, T, THelp = void, TError = never>(parser: Parser<M, TValue, TState>, context: ConfigContext<T, ConfigMeta>, options: SingleFileOptions<TValue, THelp, TError>): Promise<TValue>;
321
- declare function runWithConfig<M extends "sync" | "async", TValue, TState, T, TConfigMeta = ConfigMeta, THelp = void, TError = never>(parser: Parser<M, TValue, TState>, context: ConfigContext<T, TConfigMeta>, options: CustomLoadOptions<TValue, TConfigMeta, THelp, TError>): Promise<TValue>;
322
- //#endregion
323
- export { ConfigLoadResult, CustomLoadOptions, RunWithConfigOptions, SingleFileOptions, runWithConfig };