2
>
// Platform agnostic entrypoint for yargs, i.e., this factory is used to
3
>
// create an instance of yargs for CJS, ESM, Deno.
4
>
//
5
>
// Works by accepting a shim which shims methods that contain platform
6
>
// specific logic.
7
>
import {
8
>
command as Command,
9
>
CommandInstance,
10
>
CommandHandler,
11
>
CommandBuilderDefinition,
12
>
CommandBuilder,
13
>
CommandHandlerCallback,
14
>
CommandHandlerDefinition,
15
>
DefinitionOrCommandName,
16
>
} from './command.js';
17
>
import type {
18
>
Dictionary,
19
>
KeyOf,
20
>
DictionaryKeyof,
21
>
ValueOf,
22
>
RequireDirectoryOptions,
23
>
PlatformShim,
24
>
RequireType,
25
>
nil,
26
>
} from './typings/common-types.js';
27
>
import {
28
>
assertNotStrictEqual,
29
>
assertSingleKey,
30
>
objectKeys,
31
>
} from './typings/common-types.js';
32
>
import {
33
>
ArgsOutput,
34
>
DetailedArguments as ParserDetailedArguments,
35
>
Configuration as ParserConfiguration,
36
>
Options as ParserOptions,
37
>
ConfigCallback,
38
>
CoerceCallback,
39
>
} from './typings/yargs-parser-types.js';
40
>
import {YError} from './yerror.js';
41
>
import {UsageInstance, FailureFunction, usage as Usage} from './usage.js';
42
>
import {argsert} from './argsert.js';
43
>
import {
44
>
completion as Completion,
45
>
CompletionInstance,
46
>
CompletionFunction,
47
>
} from './completion.js';
48
>
import {
49
>
validation as Validation,
50
>
ValidationInstance,
51
>
KeyOrPos,
52
>
} from './validation.js';
53
>
import {objFilter} from './utils/obj-filter.js';
54
>
import {applyExtends} from './utils/apply-extends.js';
55
>
import {
56
>
applyMiddleware,
57
>
GlobalMiddleware,
58
>
MiddlewareCallback,
59
>
Middleware,
60
>
} from './middleware.js';
61
>
import {isPromise} from './utils/is-promise.js';
62
>
import {maybeAsyncResult} from './utils/maybe-async-result.js';
63
>
import setBlocking from './utils/set-blocking.js';
64
>
65
>
export function YargsFactory(_shim: PlatformShim) {
66
>
return (
67
processArgs: string | string[] = [],
68
cwd = _shim.process.cwd(),