@thi.ng/args 2.3.31 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-20T14:42:45Z
3
+ - **Last updated**: 2024-05-08T18:24:31Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
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.31",
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",
@@ -27,7 +27,7 @@
27
27
  "build": "yarn build:esbuild && yarn build:decl",
28
28
  "build:decl": "tsc --declaration --emitDeclarationOnly",
29
29
  "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
30
- "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
30
+ "clean": "bun ../../tools/src/clean-package.ts",
31
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
32
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
@@ -36,19 +36,18 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.0",
40
- "@thi.ng/checks": "^3.6.2",
41
- "@thi.ng/errors": "^2.5.5",
42
- "@thi.ng/logger": "^3.0.10",
43
- "@thi.ng/strings": "^3.7.31",
44
- "@thi.ng/text-format": "^2.2.3"
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.0",
48
- "esbuild": "^0.20.2",
49
- "rimraf": "^5.0.5",
50
- "typedoc": "^0.25.12",
51
- "typescript": "^5.4.3"
47
+ "@microsoft/api-extractor": "^7.43.2",
48
+ "esbuild": "^0.21.1",
49
+ "typedoc": "^0.25.13",
50
+ "typescript": "^5.4.5"
52
51
  },
53
52
  "keywords": [
54
53
  "argument",
@@ -104,5 +103,5 @@
104
103
  "thi.ng": {
105
104
  "year": 2018
106
105
  },
107
- "gitHead": "8339d05ecc857e529c7325a9839c0063b89e728d\n"
106
+ "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
108
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
  }