cli-nano 1.0.2 → 1.1.0
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/README.md +58 -1
- package/dist/__tests__/parse-args.spec.d.ts +1 -0
- package/dist/__tests__/parse-args.spec.js +16083 -0
- package/dist/__tests__/parse-args.spec.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -264
- package/dist/interfaces-CqSzltdU.d.ts +84 -0
- package/dist/interfaces-CqSzltdU.d.ts.map +1 -0
- package/dist/interfaces.d.ts +2 -44
- package/dist/interfaces.js +0 -2
- package/dist/magic-string.es-MPKlglyd.js +1015 -0
- package/dist/magic-string.es-MPKlglyd.js.map +1 -0
- package/dist/src-DQnZ842s.js +217 -0
- package/dist/src-DQnZ842s.js.map +1 -0
- package/package.json +6 -2
- package/src/index.ts +79 -79
- package/src/interfaces.ts +60 -3
- package/dist/index.js.map +0 -1
- package/dist/interfaces.d.ts.map +0 -1
- package/dist/interfaces.js.map +0 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -13
- package/dist/utils.js.map +0 -1
- package/src/utils.ts +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject } from "./interfaces-CqSzltdU.js";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare function parseArgs<C extends Config>(config: C): ArgsResult<C>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject, parseArgs };
|
|
4
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBASgB,oBAAoB,gBAAgB,IAAI,WAAW;AAAnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,264 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Normalize args to support --option=value and -o=value
|
|
5
|
-
const args = process.argv.slice(2).flatMap(arg => {
|
|
6
|
-
if (/^--?\w[\w-]*=/.test(arg)) {
|
|
7
|
-
const [flag, ...rest] = arg.split('=');
|
|
8
|
-
return [flag, rest.join('=')];
|
|
9
|
-
}
|
|
10
|
-
return arg;
|
|
11
|
-
});
|
|
12
|
-
const result = {};
|
|
13
|
-
// Check for duplicate aliases
|
|
14
|
-
const aliasMap = new Map();
|
|
15
|
-
for (const [key, opt] of Object.entries(options)) {
|
|
16
|
-
if (opt.alias) {
|
|
17
|
-
const optAlias = opt.alias;
|
|
18
|
-
if (aliasMap.has(optAlias)) {
|
|
19
|
-
throw new Error(`Duplicate alias detected: "${opt.alias}" used for both "${aliasMap.get(optAlias)}" and "${key}"`);
|
|
20
|
-
}
|
|
21
|
-
aliasMap.set(optAlias, key);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// Handle --help and --version before anything else
|
|
25
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
26
|
-
printHelp(config);
|
|
27
|
-
process.exit(0);
|
|
28
|
-
}
|
|
29
|
-
if ((version && args.includes('--version')) || args.includes('-v')) {
|
|
30
|
-
console.log(version || 'No version specified');
|
|
31
|
-
process.exit(0);
|
|
32
|
-
}
|
|
33
|
-
// Validate: required positionals must come before optional ones
|
|
34
|
-
const positionals = command.positionals ?? [];
|
|
35
|
-
let foundOptional = false;
|
|
36
|
-
for (const pos of positionals) {
|
|
37
|
-
if (!pos.required) {
|
|
38
|
-
foundOptional = true;
|
|
39
|
-
}
|
|
40
|
-
if (foundOptional && pos.required) {
|
|
41
|
-
throw new Error(`Invalid positional argument configuration: required positional "${pos.name}" cannot follow optional positional(s).`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Handle positional arguments
|
|
45
|
-
let argIndex = 0;
|
|
46
|
-
const nonOptionArgs = [];
|
|
47
|
-
while (argIndex < args.length && !args[argIndex].startsWith('-')) {
|
|
48
|
-
nonOptionArgs.push(args[argIndex]);
|
|
49
|
-
argIndex++;
|
|
50
|
-
}
|
|
51
|
-
let nonOptionIndex = 0;
|
|
52
|
-
for (let i = 0; i < positionals.length; i++) {
|
|
53
|
-
const pos = positionals[i];
|
|
54
|
-
if (pos.variadic) {
|
|
55
|
-
const remaining = positionals.length - (i + 1);
|
|
56
|
-
const values = nonOptionArgs.slice(nonOptionIndex, nonOptionArgs.length - remaining);
|
|
57
|
-
if (pos.required && values.length === 0) {
|
|
58
|
-
const usagePositionals = positionals.map(posArg => `<${posArg.name}>`).join(' ');
|
|
59
|
-
throw new Error(`Missing required positional argument, i.e.: "${command.name} ${usagePositionals}"`);
|
|
60
|
-
}
|
|
61
|
-
result[pos.name] = !pos.required && values.length === 0 && pos.default !== undefined ? pos.default : values;
|
|
62
|
-
nonOptionIndex += values.length;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
const value = nonOptionArgs[nonOptionIndex];
|
|
66
|
-
// Check if there are enough args left for required positionals
|
|
67
|
-
const requiredLeft = positionals.slice(i).filter(p => p.required).length;
|
|
68
|
-
const argsLeft = nonOptionArgs.length - nonOptionIndex;
|
|
69
|
-
if (value !== undefined && (argsLeft > requiredLeft - (pos.required ? 1 : 0) || pos.required)) {
|
|
70
|
-
result[pos.name] = value;
|
|
71
|
-
nonOptionIndex++;
|
|
72
|
-
}
|
|
73
|
-
else if (!pos.required && pos.default !== undefined) {
|
|
74
|
-
result[pos.name] = pos.default;
|
|
75
|
-
}
|
|
76
|
-
else if (pos.required) {
|
|
77
|
-
const usagePositionals = positionals.map(posArg => `<${posArg.name}>`).join(' ');
|
|
78
|
-
throw new Error(`Missing required positional argument, i.e.: "${command.name} ${usagePositionals}"`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Handle options
|
|
83
|
-
// Start parsing options after all non-option args used for positionals
|
|
84
|
-
argIndex = 0;
|
|
85
|
-
const consumedArgs = new Set();
|
|
86
|
-
// Mark all nonOptionArgs indices as consumed for positionals
|
|
87
|
-
let tempNonOptionIndex = 0;
|
|
88
|
-
for (let i = 0; i < positionals.length; i++) {
|
|
89
|
-
const pos = positionals[i];
|
|
90
|
-
if (pos.variadic) {
|
|
91
|
-
const remaining = positionals.length - (i + 1);
|
|
92
|
-
const values = nonOptionArgs.slice(tempNonOptionIndex, nonOptionArgs.length - remaining);
|
|
93
|
-
for (let j = tempNonOptionIndex; j < tempNonOptionIndex + values.length; j++) {
|
|
94
|
-
consumedArgs.add(args.findIndex((a, idx) => !a.startsWith('-') && !consumedArgs.has(idx) && a === nonOptionArgs[j]));
|
|
95
|
-
}
|
|
96
|
-
tempNonOptionIndex += values.length;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const value = nonOptionArgs[tempNonOptionIndex++];
|
|
100
|
-
consumedArgs.add(args.findIndex((a, idx) => !a.startsWith('-') && !consumedArgs.has(idx) && a === value));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
while (argIndex < args.length) {
|
|
104
|
-
if (consumedArgs.has(argIndex)) {
|
|
105
|
-
argIndex++;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const argOrg = args[argIndex] || '';
|
|
109
|
-
let arg = args[argIndex];
|
|
110
|
-
let option;
|
|
111
|
-
let configKey;
|
|
112
|
-
if (argOrg.startsWith('-')) {
|
|
113
|
-
if (argOrg.startsWith('--')) {
|
|
114
|
-
arg = argOrg.slice(2);
|
|
115
|
-
// Try all forms: as-is, kebab-to-camel, camel-to-kebab
|
|
116
|
-
option = options[arg] || options[kebabToCamel(arg)] || options[camelToKebab(arg).replace(/-/g, '')];
|
|
117
|
-
if (option) {
|
|
118
|
-
// Find the actual config key
|
|
119
|
-
for (const key of Object.keys(options)) {
|
|
120
|
-
if (options[key] === option) {
|
|
121
|
-
configKey = key;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (!option) {
|
|
127
|
-
// Try matching aliases in all forms
|
|
128
|
-
for (const key of Object.keys(options)) {
|
|
129
|
-
const opt = options[key];
|
|
130
|
-
if (opt.alias && (opt.alias.includes(arg) || opt.alias.includes(kebabToCamel(arg)) || opt.alias.includes(camelToKebab(arg)))) {
|
|
131
|
-
option = opt;
|
|
132
|
-
configKey = key;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (argOrg.startsWith('-')) {
|
|
139
|
-
// alias
|
|
140
|
-
arg = argOrg.slice(1);
|
|
141
|
-
if (arg) {
|
|
142
|
-
const optionKeys = Object.keys(options);
|
|
143
|
-
for (let j = 0; j < optionKeys.length; j++) {
|
|
144
|
-
const opt = options[optionKeys[j]];
|
|
145
|
-
if (opt.alias && (opt.alias === arg || opt.alias === kebabToCamel(arg) || opt.alias === camelToKebab(arg))) {
|
|
146
|
-
option = opt;
|
|
147
|
-
configKey = optionKeys[j];
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (!option) {
|
|
154
|
-
// Handle negated boolean in both forms
|
|
155
|
-
const isNegated = arg.startsWith('no-');
|
|
156
|
-
const optionName = isNegated ? arg.slice(3) : arg;
|
|
157
|
-
const camelOptionName = kebabToCamel(optionName);
|
|
158
|
-
option = options[optionName] || options[camelOptionName];
|
|
159
|
-
configKey = camelOptionName in options ? camelOptionName : optionName;
|
|
160
|
-
if (option?.type === 'boolean') {
|
|
161
|
-
if (result[optionName] !== undefined || result[camelOptionName] !== undefined) {
|
|
162
|
-
throw new Error('Providing same negated and truthy argument are not allowed');
|
|
163
|
-
}
|
|
164
|
-
result[configKey] = !isNegated;
|
|
165
|
-
argIndex++;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (!option || !configKey) {
|
|
170
|
-
throw new Error(`Unknown CLI option: ${arg}`);
|
|
171
|
-
}
|
|
172
|
-
switch (option.type) {
|
|
173
|
-
case 'boolean':
|
|
174
|
-
if (result[configKey] !== undefined) {
|
|
175
|
-
throw new Error('Providing same negated and truthy argument are not allowed');
|
|
176
|
-
}
|
|
177
|
-
result[configKey] = !argOrg.startsWith('--no-') && !argOrg.startsWith('-no-');
|
|
178
|
-
break;
|
|
179
|
-
case 'number':
|
|
180
|
-
if (args[argIndex + 1] === undefined || args[argIndex + 1].startsWith('-')) {
|
|
181
|
-
throw new Error(`Missing value for option: ${configKey}`);
|
|
182
|
-
}
|
|
183
|
-
result[configKey] = Number(args[++argIndex]);
|
|
184
|
-
break;
|
|
185
|
-
case 'array': {
|
|
186
|
-
if (!result[configKey])
|
|
187
|
-
result[configKey] = [];
|
|
188
|
-
const arrayValue = args[++argIndex];
|
|
189
|
-
if (arrayValue === undefined || arrayValue.startsWith('-')) {
|
|
190
|
-
throw new Error(`Missing value for array option: ${configKey}`);
|
|
191
|
-
}
|
|
192
|
-
result[configKey].push(arrayValue);
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
case 'string':
|
|
196
|
-
default:
|
|
197
|
-
if (args[argIndex + 1] === undefined || args[argIndex + 1].startsWith('-')) {
|
|
198
|
-
throw new Error(`Missing value for option: ${configKey}`);
|
|
199
|
-
}
|
|
200
|
-
result[configKey] = args[++argIndex];
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
throw new Error(`Unknown argument: ${arg}`);
|
|
206
|
-
}
|
|
207
|
-
argIndex++;
|
|
208
|
-
}
|
|
209
|
-
// After all parsing, assign any `default` CLI options when undefined
|
|
210
|
-
// and check for any missing `required` CLI options
|
|
211
|
-
Object.entries(options).forEach(([key, opt]) => {
|
|
212
|
-
if (result[key] === undefined && opt.default !== undefined) {
|
|
213
|
-
result[key] = opt.default;
|
|
214
|
-
}
|
|
215
|
-
if (opt.required && result[key] === undefined) {
|
|
216
|
-
const aliasStr = opt.alias ? `-${opt.alias}, ` : '';
|
|
217
|
-
throw new Error(`Missing required option: ${aliasStr}--${key}`);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
/** print CLI help documentation to the screen */
|
|
223
|
-
function printHelp(config) {
|
|
224
|
-
const { command, options, version } = config;
|
|
225
|
-
// Helper to truncate with ellipsis
|
|
226
|
-
function truncateDesc(desc, max) {
|
|
227
|
-
return desc.length > max ? `${desc.slice(0, max - 3)}...` : desc;
|
|
228
|
-
}
|
|
229
|
-
// Build usage string for positionals
|
|
230
|
-
const usagePositionals = (command.positionals ?? [])
|
|
231
|
-
.map(p => {
|
|
232
|
-
const variadic = p.variadic ? '..' : '';
|
|
233
|
-
if (p.required) {
|
|
234
|
-
return `<${p.name}${variadic}>`;
|
|
235
|
-
}
|
|
236
|
-
return `[${p.name}${variadic}]`;
|
|
237
|
-
})
|
|
238
|
-
.join(' ');
|
|
239
|
-
console.log('Usage:');
|
|
240
|
-
console.log(` ${command.name} ${usagePositionals} [options] ${command.description}`);
|
|
241
|
-
console.log('\nPositionals:');
|
|
242
|
-
command.positionals?.forEach(arg => {
|
|
243
|
-
let desc = truncateDesc(arg.description, 65);
|
|
244
|
-
desc = desc.padEnd(65); // Always pad to 65 chars for alignment
|
|
245
|
-
console.log(` ${arg.name.padEnd(20)}${desc} [${arg.type || 'string'}]`);
|
|
246
|
-
});
|
|
247
|
-
console.log('\nOptions:');
|
|
248
|
-
Object.keys(options).forEach(key => {
|
|
249
|
-
const option = options[key];
|
|
250
|
-
const requiredStr = option.required ? '[required]' : '';
|
|
251
|
-
const aliasStr = option.alias ? `-${option.alias}, ` : '';
|
|
252
|
-
let desc = truncateDesc(option.description || '', 65);
|
|
253
|
-
desc = desc.padEnd(65); // Always pad to 65 chars for alignment
|
|
254
|
-
console.log(` ${aliasStr.padEnd(4)}--${key.padEnd(14)}${desc} [${option.type || 'string'}]${requiredStr}`);
|
|
255
|
-
});
|
|
256
|
-
// Print default options (help and version)
|
|
257
|
-
console.log('\nDefault options:');
|
|
258
|
-
console.log(`${padString(' -h, --help', 21)} ${padString('Show help', 65)} [boolean]`);
|
|
259
|
-
if (version) {
|
|
260
|
-
console.log(`${padString(' -v, --version', 21)} ${padString('Show version number', 65)} [boolean]`);
|
|
261
|
-
}
|
|
262
|
-
console.log('\n');
|
|
263
|
-
}
|
|
264
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { parseArgs } from "./src-DQnZ842s.js";
|
|
2
|
+
|
|
3
|
+
export { parseArgs };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/interfaces.d.ts
|
|
2
|
+
interface ArgumentOptions {
|
|
3
|
+
/** option type */
|
|
4
|
+
type?: 'string' | 'boolean' | 'number' | 'array';
|
|
5
|
+
/** description of the flag option */
|
|
6
|
+
description: string;
|
|
7
|
+
/** defaults to undefined, provide shorter alias as command options */
|
|
8
|
+
alias?: string;
|
|
9
|
+
/** default value for the option if not provided */
|
|
10
|
+
default?: any;
|
|
11
|
+
/** defaults to false, is the option required? */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface PositionalArgument {
|
|
15
|
+
/** positional argument name (it will be displayed in the help docs) */
|
|
16
|
+
name: string;
|
|
17
|
+
/** positional argument description */
|
|
18
|
+
description: string;
|
|
19
|
+
/** postional argument type */
|
|
20
|
+
type?: 'string' | 'boolean' | 'number' | 'array';
|
|
21
|
+
/** defaults to false, allows multiple values for this positional argument */
|
|
22
|
+
variadic?: boolean;
|
|
23
|
+
/** default value for the option if not provided */
|
|
24
|
+
default?: any;
|
|
25
|
+
/** defaults to false, is the positional argument required? */
|
|
26
|
+
required?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface CommandOptions {
|
|
29
|
+
/** command name, used in the help docs */
|
|
30
|
+
name: string;
|
|
31
|
+
/** command description */
|
|
32
|
+
description: string;
|
|
33
|
+
/** list of positional arguments */
|
|
34
|
+
positionals?: readonly PositionalArgument[];
|
|
35
|
+
}
|
|
36
|
+
/** CLI options */
|
|
37
|
+
interface Config {
|
|
38
|
+
/** CLI definition */
|
|
39
|
+
command: CommandOptions;
|
|
40
|
+
/** option name length (w/wo alias) shown in the help (defaults to 20) */
|
|
41
|
+
helpOptLength?: number;
|
|
42
|
+
/** description length shown in the help (defaults to 65) */
|
|
43
|
+
helpDescLength?: number;
|
|
44
|
+
/** CLI list of flag options */
|
|
45
|
+
options: Record<string, ArgumentOptions>;
|
|
46
|
+
/** CLI or package version */
|
|
47
|
+
version?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Utility type to map ArgumentOptions/PositionalArgument to their value type */
|
|
50
|
+
type ArgValueType<T extends {
|
|
51
|
+
type?: string;
|
|
52
|
+
default?: any;
|
|
53
|
+
variadic?: boolean;
|
|
54
|
+
required?: boolean;
|
|
55
|
+
}> = T['type'] extends 'boolean' ? boolean : T['type'] extends 'number' ? number : T['type'] extends 'array' ? T extends {
|
|
56
|
+
variadic: true;
|
|
57
|
+
} ? T extends {
|
|
58
|
+
required: true;
|
|
59
|
+
} ? [string, ...string[]] : string[] : string | string[] : T['type'] extends 'string' ? T extends {
|
|
60
|
+
variadic: true;
|
|
61
|
+
} ? T extends {
|
|
62
|
+
required: true;
|
|
63
|
+
} ? [string, ...string[]] : string[] : string : T['type'] extends undefined ? T extends {
|
|
64
|
+
variadic: true;
|
|
65
|
+
} ? T extends {
|
|
66
|
+
required: true;
|
|
67
|
+
} ? [string, ...string[]] : string[] : string : T['default'] extends undefined ? string : T['default'];
|
|
68
|
+
/** Helper to get required keys */
|
|
69
|
+
type RequiredKeys<T> = { [K in keyof T]: T[K] extends {
|
|
70
|
+
required: true;
|
|
71
|
+
} ? K : never }[keyof T];
|
|
72
|
+
/** Helper to get optional keys */
|
|
73
|
+
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
|
74
|
+
/** Map options record to an object type with required/optional properties */
|
|
75
|
+
type OptionsToObject<T extends Record<string, any>> = { [K in RequiredKeys<T>]: ArgValueType<T[K]> } & { [K in OptionalKeys<T>]?: ArgValueType<T[K]> };
|
|
76
|
+
/** Map positionals array to an object type with required/optional properties */
|
|
77
|
+
type PositionalsToObject<T extends readonly PositionalArgument[] | undefined> = T extends readonly [infer P, ...infer Rest] ? P extends PositionalArgument ? (P['required'] extends true ? { [K in P['name']]: ArgValueType<P> } : { [K in P['name']]?: ArgValueType<P> }) & PositionalsToObject<Rest extends readonly PositionalArgument[] ? Rest : []> : PositionalsToObject<Rest extends readonly PositionalArgument[] ? Rest : []> : {
|
|
78
|
+
[key: string]: never;
|
|
79
|
+
};
|
|
80
|
+
/** The full result type for parseArgs */
|
|
81
|
+
type ArgsResult<C extends Config> = PositionalsToObject<C['command']['positionals']> & OptionsToObject<C['options']>;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject };
|
|
84
|
+
//# sourceMappingURL=interfaces-CqSzltdU.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces-CqSzltdU.d.ts","names":[],"sources":["../src/interfaces.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA;EAiBA,IAAA,CAAA,EAAA,QAAA,GAAA,SAAkB,GAAA,QAAA,GAAA,OAAA;EAoBlB;EAYA,WAAM,EAAA,MAAA;EAAA;EAAA,KAEZ,CAAA,EAAA,MAAA;EAAc;EASgB,OAA9B,CAAA,E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C,CAQ5C,SAAA,SAAA,CAAA,KAAA,EAAA,EAAA,GAAA,KAAA,KAAA,CAAA,GAPvC,CAOuC,SAP7B,kBAO6B,GAAA,CANpC,CAMoC,CAAA,UAAA,CAAA,SAAA,IAAA,GAAA,QANC,CAMkE,CAAA,MAAA,CAAA,GANtD,YAMsD,CANzC,CAMyC,CAAA,EAAC,GAAA,QAN3B,CAMyB,CAAA,MAAA,CAAA,IANZ,YAMY,CANC,CAMD,CAAA,MALrG,oBAAoB,sBAAsB,uBAAuB,aACnE,oBAAoB,sBAAsB,uBAAuB;;;;KAI3D,qBAAqB,UAAU,oBAAoB,+BAA+B,gBAAgB"}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type?: 'string' | 'boolean' | 'number' | 'array';
|
|
4
|
-
/** description of the flag option */
|
|
5
|
-
description: string;
|
|
6
|
-
/** defaults to undefined, provide shorter aliases as command options */
|
|
7
|
-
alias?: string | string[];
|
|
8
|
-
/** default value for the option if not provided */
|
|
9
|
-
default?: any;
|
|
10
|
-
/** defaults to false, is the option required? */
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface PositionalArgument {
|
|
14
|
-
/** positional argument name (it will be displayed in the help docs) */
|
|
15
|
-
name: string;
|
|
16
|
-
/** positional argument description */
|
|
17
|
-
description: string;
|
|
18
|
-
/** postional argument type */
|
|
19
|
-
type?: 'string' | 'boolean' | 'number' | 'array';
|
|
20
|
-
/** defaults to false, allows multiple values for this positional argument */
|
|
21
|
-
variadic?: boolean;
|
|
22
|
-
/** default value for the option if not provided */
|
|
23
|
-
default?: any;
|
|
24
|
-
/** defaults to false, is the positional argument required? */
|
|
25
|
-
required?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface CommandOptions {
|
|
28
|
-
/** command name, used in the help docs */
|
|
29
|
-
name: string;
|
|
30
|
-
/** command description */
|
|
31
|
-
description: string;
|
|
32
|
-
/** list of positional arguments */
|
|
33
|
-
positionals?: PositionalArgument[];
|
|
34
|
-
}
|
|
35
|
-
/** CLI options */
|
|
36
|
-
export interface Config {
|
|
37
|
-
/** CLI definition */
|
|
38
|
-
command: CommandOptions;
|
|
39
|
-
/** CLI list of flag options */
|
|
40
|
-
options: Record<string, ArgumentOptions>;
|
|
41
|
-
/** CLI or package version */
|
|
42
|
-
version?: string;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=interfaces.d.ts.map
|
|
1
|
+
import { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject } from "./interfaces-CqSzltdU.js";
|
|
2
|
+
export { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject };
|
package/dist/interfaces.js
CHANGED