vovk 1.0.1 → 1.0.3
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.
|
@@ -21,14 +21,19 @@ function parseCommandLineArgs() {
|
|
|
21
21
|
for (let i = 0; i < commandArgs.length; i++) {
|
|
22
22
|
const arg = commandArgs[i];
|
|
23
23
|
if (arg.startsWith('--')) {
|
|
24
|
-
|
|
24
|
+
/** @type {string} */
|
|
25
|
+
let key = arg.slice(2);
|
|
25
26
|
/** @type {string | true} */
|
|
26
|
-
let value
|
|
27
|
+
let value; // Assume flag is boolean unless a value is found
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (arg.includes('=')) {
|
|
30
|
+
[key, value] = arg.slice(2).split('=');
|
|
31
|
+
} else if (i + 1 < commandArgs.length && !commandArgs[i + 1].startsWith('--')) {
|
|
32
|
+
// Look ahead to next arg if it exists and is not a flag
|
|
30
33
|
value = commandArgs[i + 1];
|
|
31
34
|
i++; // Skip next arg since it's consumed as a value here
|
|
35
|
+
} else {
|
|
36
|
+
value = true;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
const camelKey = /** @type {keyof Flags} */ (toCamelCase(key));
|
|
@@ -39,8 +44,6 @@ function parseCommandLineArgs() {
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
if (!command) throw new Error('No command provided');
|
|
43
|
-
|
|
44
47
|
return { command, flags, restArgs };
|
|
45
48
|
}
|
|
46
49
|
|