args-tokens 0.2.5 → 0.3.1

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.
@@ -1,64 +1,3 @@
1
- /**
2
- * Argument token Kind
3
- * - `option`: option token, support short option (e.g. `-x`) and long option (e.g. `--foo`)
4
- * - `option-terminator`: option terminator (`--`) token, see guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
5
- * - `positional`: positional token
6
- */
7
- export type ArgTokenKind = 'option' | 'option-terminator' | 'positional';
8
- /**
9
- * Argument token
10
- */
11
- export interface ArgToken {
12
- /**
13
- * Argument token kind
14
- */
15
- kind: ArgTokenKind;
16
- /**
17
- * Argument token index, e.g `--foo bar` => `--foo` index is 0, `bar` index is 1
18
- */
19
- index: number;
20
- /**
21
- * Option name, e.g. `--foo` => `foo`, `-x` => `x`
22
- */
23
- name?: string;
24
- /**
25
- * Raw option name, e.g. `--foo` => `--foo`, `-x` => `-x`
26
- */
27
- rawName?: string;
28
- /**
29
- * Option value, e.g. `--foo=bar` => `bar`, `-x=bar` => `bar`.
30
- * If the `allowCompatible` option is `true`, short option value will be same as Node.js `parseArgs` behavior.
31
- */
32
- value?: string;
33
- /**
34
- * Inline value, e.g. `--foo=bar` => `true`, `-x=bar` => `true`.
35
- */
36
- inlineValue?: boolean;
37
- }
38
- /**
39
- * Parse Options
40
- */
41
- export interface ParseOptions {
42
- /**
43
- * [Node.js parseArgs](https://nodejs.org/api/util.html#parseargs-tokens) tokens compatible mode
44
- * @default false
45
- */
46
- allowCompatible?: boolean;
47
- }
48
- /**
49
- * Parse command line arguments
50
- * @example
51
- * ```js
52
- * import { parseArgs } from 'args-tokens' // for Node.js and Bun
53
- * // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
54
- *
55
- * const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
56
- * // do something with using tokens
57
- * // ...
58
- * console.log('tokens:', tokens)
59
- * ```
60
- * @param args command line arguments
61
- * @param options parse options
62
- * @returns argument tokens
63
- */
64
- export declare function parseArgs(args: string[], options?: ParseOptions): ArgToken[];
1
+ export { parseArgs } from './parser.js';
2
+ export * from './resolver.js';
3
+ export type { ArgToken, ParseOptions } from './parser';
package/lib/cjs/index.js CHANGED
@@ -1,228 +1,20 @@
1
1
  "use strict";
2
- // SPDX-License-Identifier: MIT
3
- // Modifier: kazuya kawaguchi (a.k.a. kazupon)
4
- // Forked from `nodejs/node` (`pkgjs/parseargs`)
5
- // Repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
6
- // Author: Node.js contributors
7
- // Code url: https://github.com/nodejs/node/blob/main/lib/internal/util/parse_args/parse_args.js
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.parseArgs = parseArgs;
10
- const HYPHEN_CHAR = '-';
11
- const HYPHEN_CODE = HYPHEN_CHAR.codePointAt(0);
12
- const EQUAL_CHAR = '=';
13
- const EQUAL_CODE = EQUAL_CHAR.codePointAt(0);
14
- const TERMINATOR = '--';
15
- const SHORT_OPTION_PREFIX = HYPHEN_CHAR;
16
- const LONG_OPTION_PREFIX = '--';
17
- /**
18
- * Parse command line arguments
19
- * @example
20
- * ```js
21
- * import { parseArgs } from 'args-tokens' // for Node.js and Bun
22
- * // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
23
- *
24
- * const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
25
- * // do something with using tokens
26
- * // ...
27
- * console.log('tokens:', tokens)
28
- * ```
29
- * @param args command line arguments
30
- * @param options parse options
31
- * @returns argument tokens
32
- */
33
- function parseArgs(args, options = {}) {
34
- const { allowCompatible = false } = options;
35
- const tokens = [];
36
- const remainings = [...args];
37
- let index = -1;
38
- let groupCount = 0;
39
- let hasShortValueSeparator = false;
40
- while (remainings.length > 0) {
41
- const arg = remainings.shift();
42
- if (arg == undefined) {
43
- break;
44
- }
45
- const nextArg = remainings[0];
46
- if (groupCount > 0) {
47
- groupCount--;
48
- }
49
- else {
50
- index++;
51
- }
52
- // check if `arg` is an options terminator.
53
- // guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
54
- if (arg === TERMINATOR) {
55
- tokens.push({
56
- kind: 'option-terminator',
57
- index
58
- });
59
- const mapped = remainings.map(arg => {
60
- return { kind: 'positional', index: ++index, value: arg };
61
- });
62
- tokens.push(...mapped);
63
- break;
64
- }
65
- if (isShortOption(arg)) {
66
- const shortOption = arg.charAt(1);
67
- let value;
68
- let inlineValue;
69
- if (groupCount) {
70
- // e.g. `-abc`
71
- tokens.push({
72
- kind: 'option',
73
- name: shortOption,
74
- rawName: arg,
75
- index,
76
- value,
77
- inlineValue
78
- });
79
- if (groupCount === 1 && hasOptionValue(nextArg)) {
80
- value = remainings.shift();
81
- if (hasShortValueSeparator) {
82
- inlineValue = true;
83
- hasShortValueSeparator = false;
84
- }
85
- tokens.push({
86
- kind: 'option',
87
- index,
88
- value,
89
- inlineValue
90
- });
91
- }
92
- }
93
- else {
94
- // e.g. `-a`
95
- tokens.push({
96
- kind: 'option',
97
- name: shortOption,
98
- rawName: arg,
99
- index,
100
- value,
101
- inlineValue
102
- });
103
- }
104
- // eslint-disable-next-line unicorn/no-null
105
- if (value != null) {
106
- ++index;
107
- }
108
- continue;
109
- }
110
- if (isShortOptionGroup(arg)) {
111
- // expend short option group (e.g. `-abc` => `-a -b -c`, `-f=bar` => `-f bar`)
112
- const expanded = [];
113
- let shortValue = '';
114
- for (let i = 1; i < arg.length; i++) {
115
- const shortableOption = arg.charAt(i);
116
- if (hasShortValueSeparator) {
117
- shortValue += shortableOption;
118
- }
119
- else {
120
- if (!allowCompatible && shortableOption.codePointAt(0) === EQUAL_CODE) {
121
- hasShortValueSeparator = true;
122
- }
123
- else {
124
- expanded.push(`${SHORT_OPTION_PREFIX}${shortableOption}`);
125
- }
126
- }
127
- }
128
- if (shortValue) {
129
- expanded.push(shortValue);
130
- }
131
- remainings.unshift(...expanded);
132
- groupCount = expanded.length;
133
- continue;
134
- }
135
- if (isLongOption(arg)) {
136
- // e.g. `--foo`
137
- const longOption = arg.slice(2);
138
- tokens.push({
139
- kind: 'option',
140
- name: longOption,
141
- rawName: arg,
142
- index,
143
- value: undefined,
144
- inlineValue: undefined
145
- });
146
- continue;
147
- }
148
- if (isLongOptionAndValue(arg)) {
149
- // e.g. `--foo=bar`
150
- const equalIndex = arg.indexOf(EQUAL_CHAR);
151
- const longOption = arg.slice(2, equalIndex);
152
- const value = arg.slice(equalIndex + 1);
153
- tokens.push({
154
- kind: 'option',
155
- name: longOption,
156
- rawName: `${LONG_OPTION_PREFIX}${longOption}`,
157
- index,
158
- value,
159
- inlineValue: true
160
- });
161
- continue;
162
- }
163
- tokens.push({
164
- kind: 'positional',
165
- index,
166
- value: arg
167
- });
168
- }
169
- return tokens;
170
- }
171
- /**
172
- * Check if `arg` is a short option (e.g. `-f`)
173
- * @param arg the argument to check
174
- * @returns whether `arg` is a short option
175
- */
176
- function isShortOption(arg) {
177
- return (arg.length === 2 && arg.codePointAt(0) === HYPHEN_CODE && arg.codePointAt(1) !== HYPHEN_CODE);
178
- }
179
- /**
180
- * Check if `arg` is a short option group (e.g. `-abc`)
181
- * @param arg the argument to check
182
- * @returns whether `arg` is a short option group
183
- */
184
- function isShortOptionGroup(arg) {
185
- if (arg.length <= 2) {
186
- return false;
187
- }
188
- if (arg.codePointAt(0) !== HYPHEN_CODE) {
189
- return false;
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
190
7
  }
191
- if (arg.codePointAt(1) === HYPHEN_CODE) {
192
- return false;
193
- }
194
- return true;
195
- }
196
- /**
197
- * Check if `arg` is a long option (e.g. `--foo`)
198
- * @param arg the argument to check
199
- * @returns whether `arg` is a long option
200
- */
201
- function isLongOption(arg) {
202
- return hasLongOptionPrefix(arg) && !arg.includes(EQUAL_CHAR, 3);
203
- }
204
- /**
205
- * Check if `arg` is a long option with value (e.g. `--foo=bar`)
206
- * @param arg the argument to check
207
- * @returns whether `arg` is a long option
208
- */
209
- function isLongOptionAndValue(arg) {
210
- return hasLongOptionPrefix(arg) && arg.includes(EQUAL_CHAR, 3);
211
- }
212
- /**
213
- * Check if `arg` is a long option prefix (e.g. `--`)
214
- * @param arg the argument to check
215
- * @returns whether `arg` is a long option prefix
216
- */
217
- function hasLongOptionPrefix(arg) {
218
- return arg.length > 2 && ~arg.indexOf(LONG_OPTION_PREFIX);
219
- }
220
- /**
221
- * Check if a `value` is an option value
222
- * @param value a value to check
223
- * @returns whether a `value` is an option value
224
- */
225
- function hasOptionValue(value) {
226
- // eslint-disable-next-line unicorn/no-null
227
- return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
228
- }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.parseArgs = void 0;
18
+ var parser_js_1 = require("./parser.js");
19
+ Object.defineProperty(exports, "parseArgs", { enumerable: true, get: function () { return parser_js_1.parseArgs; } });
20
+ __exportStar(require("./resolver.js"), exports);
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Argument token Kind
3
+ * - `option`: option token, support short option (e.g. `-x`) and long option (e.g. `--foo`)
4
+ * - `option-terminator`: option terminator (`--`) token, see guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
5
+ * - `positional`: positional token
6
+ */
7
+ type ArgTokenKind = 'option' | 'option-terminator' | 'positional';
8
+ /**
9
+ * Argument token
10
+ */
11
+ export interface ArgToken {
12
+ /**
13
+ * Argument token kind
14
+ */
15
+ kind: ArgTokenKind;
16
+ /**
17
+ * Argument token index, e.g `--foo bar` => `--foo` index is 0, `bar` index is 1
18
+ */
19
+ index: number;
20
+ /**
21
+ * Option name, e.g. `--foo` => `foo`, `-x` => `x`
22
+ */
23
+ name?: string;
24
+ /**
25
+ * Raw option name, e.g. `--foo` => `--foo`, `-x` => `-x`
26
+ */
27
+ rawName?: string;
28
+ /**
29
+ * Option value, e.g. `--foo=bar` => `bar`, `-x=bar` => `bar`.
30
+ * If the `allowCompatible` option is `true`, short option value will be same as Node.js `parseArgs` behavior.
31
+ */
32
+ value?: string;
33
+ /**
34
+ * Inline value, e.g. `--foo=bar` => `true`, `-x=bar` => `true`.
35
+ */
36
+ inlineValue?: boolean;
37
+ }
38
+ /**
39
+ * Parse Options
40
+ */
41
+ export interface ParseOptions {
42
+ /**
43
+ * [Node.js parseArgs](https://nodejs.org/api/util.html#parseargs-tokens) tokens compatible mode
44
+ * @default false
45
+ */
46
+ allowCompatible?: boolean;
47
+ }
48
+ /**
49
+ * Parse command line arguments
50
+ * @example
51
+ * ```js
52
+ * import { parseArgs } from 'args-tokens' // for Node.js and Bun
53
+ * // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
54
+ *
55
+ * const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
56
+ * // do something with using tokens
57
+ * // ...
58
+ * console.log('tokens:', tokens)
59
+ * ```
60
+ * @param args command line arguments
61
+ * @param options parse options
62
+ * @returns argument tokens
63
+ */
64
+ export declare function parseArgs(args: string[], options?: ParseOptions): ArgToken[];
65
+ /**
66
+ * Check if `arg` is a short option (e.g. `-f`)
67
+ * @param arg the argument to check
68
+ * @returns whether `arg` is a short option
69
+ */
70
+ export declare function isShortOption(arg: string): boolean;
71
+ /**
72
+ * Check if `arg` is a long option prefix (e.g. `--`)
73
+ * @param arg the argument to check
74
+ * @returns whether `arg` is a long option prefix
75
+ */
76
+ export declare function hasLongOptionPrefix(arg: string): number | false;
77
+ export {};
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MIT
3
+ // Modifier: kazuya kawaguchi (a.k.a. kazupon)
4
+ // Forked from `nodejs/node` (`pkgjs/parseargs`)
5
+ // Repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
6
+ // Author: Node.js contributors
7
+ // Code url: https://github.com/nodejs/node/blob/main/lib/internal/util/parse_args/parse_args.js
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.parseArgs = parseArgs;
10
+ exports.isShortOption = isShortOption;
11
+ exports.hasLongOptionPrefix = hasLongOptionPrefix;
12
+ const HYPHEN_CHAR = '-';
13
+ const HYPHEN_CODE = HYPHEN_CHAR.codePointAt(0);
14
+ const EQUAL_CHAR = '=';
15
+ const EQUAL_CODE = EQUAL_CHAR.codePointAt(0);
16
+ const TERMINATOR = '--';
17
+ const SHORT_OPTION_PREFIX = HYPHEN_CHAR;
18
+ const LONG_OPTION_PREFIX = '--';
19
+ /**
20
+ * Parse command line arguments
21
+ * @example
22
+ * ```js
23
+ * import { parseArgs } from 'args-tokens' // for Node.js and Bun
24
+ * // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
25
+ *
26
+ * const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
27
+ * // do something with using tokens
28
+ * // ...
29
+ * console.log('tokens:', tokens)
30
+ * ```
31
+ * @param args command line arguments
32
+ * @param options parse options
33
+ * @returns argument tokens
34
+ */
35
+ function parseArgs(args, options = {}) {
36
+ const { allowCompatible = false } = options;
37
+ const tokens = [];
38
+ const remainings = [...args];
39
+ let index = -1;
40
+ let groupCount = 0;
41
+ let hasShortValueSeparator = false;
42
+ while (remainings.length > 0) {
43
+ const arg = remainings.shift();
44
+ if (arg == undefined) {
45
+ break;
46
+ }
47
+ const nextArg = remainings[0];
48
+ if (groupCount > 0) {
49
+ groupCount--;
50
+ }
51
+ else {
52
+ index++;
53
+ }
54
+ // check if `arg` is an options terminator.
55
+ // guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
56
+ if (arg === TERMINATOR) {
57
+ tokens.push({
58
+ kind: 'option-terminator',
59
+ index
60
+ });
61
+ const mapped = remainings.map(arg => {
62
+ return { kind: 'positional', index: ++index, value: arg };
63
+ });
64
+ tokens.push(...mapped);
65
+ break;
66
+ }
67
+ if (isShortOption(arg)) {
68
+ const shortOption = arg.charAt(1);
69
+ let value;
70
+ let inlineValue;
71
+ if (groupCount) {
72
+ // e.g. `-abc`
73
+ tokens.push({
74
+ kind: 'option',
75
+ name: shortOption,
76
+ rawName: arg,
77
+ index,
78
+ value,
79
+ inlineValue
80
+ });
81
+ if (groupCount === 1 && hasOptionValue(nextArg)) {
82
+ value = remainings.shift();
83
+ if (hasShortValueSeparator) {
84
+ inlineValue = true;
85
+ hasShortValueSeparator = false;
86
+ }
87
+ tokens.push({
88
+ kind: 'option',
89
+ index,
90
+ value,
91
+ inlineValue
92
+ });
93
+ }
94
+ }
95
+ else {
96
+ // e.g. `-a`
97
+ tokens.push({
98
+ kind: 'option',
99
+ name: shortOption,
100
+ rawName: arg,
101
+ index,
102
+ value,
103
+ inlineValue
104
+ });
105
+ }
106
+ // eslint-disable-next-line unicorn/no-null
107
+ if (value != null) {
108
+ ++index;
109
+ }
110
+ continue;
111
+ }
112
+ if (isShortOptionGroup(arg)) {
113
+ // expend short option group (e.g. `-abc` => `-a -b -c`, `-f=bar` => `-f bar`)
114
+ const expanded = [];
115
+ let shortValue = '';
116
+ for (let i = 1; i < arg.length; i++) {
117
+ const shortableOption = arg.charAt(i);
118
+ if (hasShortValueSeparator) {
119
+ shortValue += shortableOption;
120
+ }
121
+ else {
122
+ if (!allowCompatible && shortableOption.codePointAt(0) === EQUAL_CODE) {
123
+ hasShortValueSeparator = true;
124
+ }
125
+ else {
126
+ expanded.push(`${SHORT_OPTION_PREFIX}${shortableOption}`);
127
+ }
128
+ }
129
+ }
130
+ if (shortValue) {
131
+ expanded.push(shortValue);
132
+ }
133
+ remainings.unshift(...expanded);
134
+ groupCount = expanded.length;
135
+ continue;
136
+ }
137
+ if (isLongOption(arg)) {
138
+ // e.g. `--foo`
139
+ const longOption = arg.slice(2);
140
+ tokens.push({
141
+ kind: 'option',
142
+ name: longOption,
143
+ rawName: arg,
144
+ index,
145
+ value: undefined,
146
+ inlineValue: undefined
147
+ });
148
+ continue;
149
+ }
150
+ if (isLongOptionAndValue(arg)) {
151
+ // e.g. `--foo=bar`
152
+ const equalIndex = arg.indexOf(EQUAL_CHAR);
153
+ const longOption = arg.slice(2, equalIndex);
154
+ const value = arg.slice(equalIndex + 1);
155
+ tokens.push({
156
+ kind: 'option',
157
+ name: longOption,
158
+ rawName: `${LONG_OPTION_PREFIX}${longOption}`,
159
+ index,
160
+ value,
161
+ inlineValue: true
162
+ });
163
+ continue;
164
+ }
165
+ tokens.push({
166
+ kind: 'positional',
167
+ index,
168
+ value: arg
169
+ });
170
+ }
171
+ return tokens;
172
+ }
173
+ /**
174
+ * Check if `arg` is a short option (e.g. `-f`)
175
+ * @param arg the argument to check
176
+ * @returns whether `arg` is a short option
177
+ */
178
+ function isShortOption(arg) {
179
+ return (arg.length === 2 && arg.codePointAt(0) === HYPHEN_CODE && arg.codePointAt(1) !== HYPHEN_CODE);
180
+ }
181
+ /**
182
+ * Check if `arg` is a short option group (e.g. `-abc`)
183
+ * @param arg the argument to check
184
+ * @returns whether `arg` is a short option group
185
+ */
186
+ function isShortOptionGroup(arg) {
187
+ if (arg.length <= 2) {
188
+ return false;
189
+ }
190
+ if (arg.codePointAt(0) !== HYPHEN_CODE) {
191
+ return false;
192
+ }
193
+ if (arg.codePointAt(1) === HYPHEN_CODE) {
194
+ return false;
195
+ }
196
+ return true;
197
+ }
198
+ /**
199
+ * Check if `arg` is a long option (e.g. `--foo`)
200
+ * @param arg the argument to check
201
+ * @returns whether `arg` is a long option
202
+ */
203
+ function isLongOption(arg) {
204
+ return hasLongOptionPrefix(arg) && !arg.includes(EQUAL_CHAR, 3);
205
+ }
206
+ /**
207
+ * Check if `arg` is a long option with value (e.g. `--foo=bar`)
208
+ * @param arg the argument to check
209
+ * @returns whether `arg` is a long option
210
+ */
211
+ function isLongOptionAndValue(arg) {
212
+ return hasLongOptionPrefix(arg) && arg.includes(EQUAL_CHAR, 3);
213
+ }
214
+ /**
215
+ * Check if `arg` is a long option prefix (e.g. `--`)
216
+ * @param arg the argument to check
217
+ * @returns whether `arg` is a long option prefix
218
+ */
219
+ function hasLongOptionPrefix(arg) {
220
+ return arg.length > 2 && ~arg.indexOf(LONG_OPTION_PREFIX);
221
+ }
222
+ /**
223
+ * Check if a `value` is an option value
224
+ * @param value a value to check
225
+ * @returns whether a `value` is an option value
226
+ */
227
+ function hasOptionValue(value) {
228
+ // eslint-disable-next-line unicorn/no-null
229
+ return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
230
+ }
@@ -0,0 +1,50 @@
1
+ import type { ArgToken } from './parser';
2
+ /**
3
+ * An option schema for an argument.
4
+ */
5
+ export interface ArgOptionSchema {
6
+ /**
7
+ * Type of argument.
8
+ */
9
+ type: 'string' | 'boolean' | 'number';
10
+ /**
11
+ * A single character alias for the option.
12
+ */
13
+ short?: string;
14
+ /**
15
+ * Whether the argument is required or not.
16
+ */
17
+ required?: true;
18
+ /**
19
+ * The default value of the argument.
20
+ */
21
+ default?: string | boolean | number;
22
+ }
23
+ /**
24
+ * An object that contains {@link ArgOptionSchema | options schema}.
25
+ */
26
+ export interface ArgOptions {
27
+ [option: string]: ArgOptionSchema;
28
+ }
29
+ /**
30
+ * An object that contains the values of the arguments.
31
+ */
32
+ export type ArgValues<T> = T extends ArgOptions ? ResolveArgValues<T, {
33
+ [Option in keyof T]: ExtractOptionValue<T[Option]>;
34
+ }> : {
35
+ [option: string]: string | boolean | number | undefined;
36
+ };
37
+ type ExtractOptionValue<O extends ArgOptionSchema> = O['type'] extends 'string' ? string : O['type'] extends 'boolean' ? boolean : O['type'] extends 'number' ? number : string | boolean | number;
38
+ type ResolveArgValues<O extends ArgOptions, V extends Record<keyof O, unknown>> = {
39
+ -readonly [Option in keyof O]?: V[Option];
40
+ } & FilterArgs<O, V, 'default'> & FilterArgs<O, V, 'required'> extends infer P ? {
41
+ [K in keyof P]: P[K];
42
+ } : never;
43
+ type FilterArgs<O extends ArgOptions, V extends Record<keyof O, unknown>, K extends keyof ArgOptionSchema> = {
44
+ [Option in keyof O as O[Option][K] extends {} ? Option : never]: V[Option];
45
+ };
46
+ export declare function resolveArgs<T extends ArgOptions>(options: T, tokens: ArgToken[]): {
47
+ values: ArgValues<T>;
48
+ positionals: string[];
49
+ };
50
+ export {};