@thi.ng/args 2.3.32 → 2.3.33
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/CHANGELOG.md +1 -1
- package/cli.js +4 -8
- package/package.json +12 -12
- package/parse.js +4 -8
package/CHANGELOG.md
CHANGED
package/cli.js
CHANGED
|
@@ -18,15 +18,13 @@ const cliApp = async (config) => {
|
|
|
18
18
|
let start = config.start ?? 2;
|
|
19
19
|
if (config.single) {
|
|
20
20
|
cmdID = Object.keys(config.commands)[0];
|
|
21
|
-
if (!cmdID)
|
|
22
|
-
illegalArgs("no command provided");
|
|
21
|
+
if (!cmdID) illegalArgs("no command provided");
|
|
23
22
|
cmd = config.commands[cmdID];
|
|
24
23
|
} else {
|
|
25
24
|
cmdID = argv[start];
|
|
26
25
|
cmd = config.commands[cmdID];
|
|
27
26
|
usageOpts.prefix += __descriptions(config.commands);
|
|
28
|
-
if (!cmd)
|
|
29
|
-
__usageAndExit(config, usageOpts);
|
|
27
|
+
if (!cmd) __usageAndExit(config, usageOpts);
|
|
30
28
|
start++;
|
|
31
29
|
}
|
|
32
30
|
let parsed;
|
|
@@ -38,8 +36,7 @@ const cliApp = async (config) => {
|
|
|
38
36
|
});
|
|
39
37
|
} catch (_) {
|
|
40
38
|
}
|
|
41
|
-
if (!parsed)
|
|
42
|
-
process.exit(1);
|
|
39
|
+
if (!parsed) process.exit(1);
|
|
43
40
|
if (cmd.inputs !== void 0 && cmd.inputs !== parsed.rest.length) {
|
|
44
41
|
process.stderr.write(`expected ${cmd.inputs || 0} input(s)
|
|
45
42
|
`);
|
|
@@ -55,8 +52,7 @@ const cliApp = async (config) => {
|
|
|
55
52
|
cmd
|
|
56
53
|
);
|
|
57
54
|
await cmd.fn(ctx);
|
|
58
|
-
if (config.post)
|
|
59
|
-
await config.post(ctx, cmd);
|
|
55
|
+
if (config.post) await config.post(ctx, cmd);
|
|
60
56
|
} catch (e) {
|
|
61
57
|
process.stderr.write(e.message + "\n\n");
|
|
62
58
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/args",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.33",
|
|
4
4
|
"description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
-
"@thi.ng/logger": "^3.0.
|
|
43
|
-
"@thi.ng/strings": "^3.7.
|
|
44
|
-
"@thi.ng/text-format": "^2.2.
|
|
39
|
+
"@thi.ng/api": "^8.11.2",
|
|
40
|
+
"@thi.ng/checks": "^3.6.4",
|
|
41
|
+
"@thi.ng/errors": "^2.5.7",
|
|
42
|
+
"@thi.ng/logger": "^3.0.12",
|
|
43
|
+
"@thi.ng/strings": "^3.7.33",
|
|
44
|
+
"@thi.ng/text-format": "^2.2.5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.43.
|
|
48
|
-
"esbuild": "^0.
|
|
49
|
-
"typedoc": "^0.25.
|
|
50
|
-
"typescript": "^5.4.
|
|
47
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
48
|
+
"esbuild": "^0.21.1",
|
|
49
|
+
"typedoc": "^0.25.13",
|
|
50
|
+
"typescript": "^5.4.5"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"argument",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"thi.ng": {
|
|
104
104
|
"year": 2018
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
107
107
|
}
|
package/parse.js
CHANGED
|
@@ -34,11 +34,9 @@ const parseOpts = (specs, argv, opts) => {
|
|
|
34
34
|
id = state.id;
|
|
35
35
|
spec = state.spec;
|
|
36
36
|
i = i + ~~(state.state < 2);
|
|
37
|
-
if (state.state)
|
|
38
|
-
break;
|
|
37
|
+
if (state.state) break;
|
|
39
38
|
} else {
|
|
40
|
-
if (parseValue(spec, acc, id, a))
|
|
41
|
-
break;
|
|
39
|
+
if (parseValue(spec, acc, id, a)) break;
|
|
42
40
|
id = null;
|
|
43
41
|
i++;
|
|
44
42
|
}
|
|
@@ -59,8 +57,7 @@ const parseKey = (specs, aliases, acc, a) => {
|
|
|
59
57
|
if (a[0] === "-") {
|
|
60
58
|
let id;
|
|
61
59
|
if (a[1] === "-") {
|
|
62
|
-
if (a === "--")
|
|
63
|
-
return { state: 1 };
|
|
60
|
+
if (a === "--") return { state: 1 };
|
|
64
61
|
id = camel(a.substring(2));
|
|
65
62
|
} else {
|
|
66
63
|
id = aliases[a.substring(1)];
|
|
@@ -71,8 +68,7 @@ const parseKey = (specs, aliases, acc, a) => {
|
|
|
71
68
|
if (spec.flag) {
|
|
72
69
|
acc[id] = true;
|
|
73
70
|
id = void 0;
|
|
74
|
-
if (spec.fn && !spec.fn("true"))
|
|
75
|
-
return { state: 1, spec };
|
|
71
|
+
if (spec.fn && !spec.fn("true")) return { state: 1, spec };
|
|
76
72
|
}
|
|
77
73
|
return { state: 0, id, spec };
|
|
78
74
|
}
|