@thi.ng/args 3.2.0 → 3.2.2

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/cli.js +9 -8
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -129,7 +129,7 @@ For Node.js REPL:
129
129
  const args = await import("@thi.ng/args");
130
130
  ```
131
131
 
132
- Package sizes (brotli'd, pre-treeshake): ESM: 3.47 KB
132
+ Package sizes (brotli'd, pre-treeshake): ESM: 3.48 KB
133
133
 
134
134
  ## Dependencies
135
135
 
package/cli.js CHANGED
@@ -32,21 +32,22 @@ const cliApp = async (config) => {
32
32
  } else {
33
33
  cmdID = argv[start];
34
34
  cmd = config.commands[cmdID];
35
- if (!cmd) {
36
- usageOpts.prefix += __descriptions(config.commands, usageOpts);
37
- __usageAndExit(config, usageOpts);
38
- } else {
35
+ if (cmd) {
39
36
  usageOpts.prefix += __descriptions(
40
37
  { [cmdID]: cmd },
41
38
  usageOpts,
42
39
  "\nCurrent command:\n"
43
40
  );
41
+ } else {
42
+ usageOpts.prefix += __descriptions(config.commands, usageOpts);
43
+ __usageAndExit(config.opts, usageOpts);
44
44
  }
45
45
  start++;
46
46
  }
47
+ const mergedOpts = { ...config.opts, ...cmd.opts };
47
48
  let parsed;
48
49
  try {
49
- parsed = parse({ ...config.opts, ...cmd.opts }, argv, {
50
+ parsed = parse(mergedOpts, argv, {
50
51
  usageOpts,
51
52
  start
52
53
  });
@@ -67,7 +68,7 @@ const cliApp = async (config) => {
67
68
  }
68
69
  if (err) {
69
70
  __printError(err, theme);
70
- __usageAndExit(config, usageOpts);
71
+ __usageAndExit(mergedOpts, usageOpts);
71
72
  }
72
73
  }
73
74
  const ctx = await config.ctx(
@@ -86,8 +87,8 @@ const cliApp = async (config) => {
86
87
  process.exit(1);
87
88
  }
88
89
  };
89
- const __usageAndExit = (config, usageOpts) => {
90
- process.stderr.write(usage(config.opts, usageOpts));
90
+ const __usageAndExit = (opts, usageOpts) => {
91
+ process.stderr.write(usage(opts, usageOpts));
91
92
  process.exit(1);
92
93
  };
93
94
  const __descriptions = (commands, { color, lineWidth = 80 } = {}, prefix = "\nAvailable commands:\n") => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/args",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Declarative, functional CLI argument/options parser, app framework, arg value coercions, multi/sub-commands, usage generation, error handling etc.",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -43,8 +43,8 @@
43
43
  "@thi.ng/checks": "^3.7.23",
44
44
  "@thi.ng/errors": "^2.5.47",
45
45
  "@thi.ng/logger": "^3.2.6",
46
- "@thi.ng/strings": "^3.9.27",
47
- "@thi.ng/text-format": "^2.2.46"
46
+ "@thi.ng/strings": "^3.9.28",
47
+ "@thi.ng/text-format": "^2.2.47"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/node": "^24.9.1",
@@ -110,5 +110,5 @@
110
110
  "tag": "cli",
111
111
  "year": 2018
112
112
  },
113
- "gitHead": "03456efcb39f1b941601e9b424275fc6530fd4f2\n"
113
+ "gitHead": "74b6f319d8f52c9266d97f616be5298a6a5b96e4\n"
114
114
  }