@thi.ng/args 2.7.1 → 2.8.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-07-11T08:24:44Z
3
+ - **Last updated**: 2025-07-12T13:21:04Z
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.
@@ -11,6 +11,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
11
11
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
12
12
  and/or version bumps of transitive dependencies.
13
13
 
14
+ ## [2.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.8.0) (2025-07-12)
15
+
16
+ #### 🚀 Features
17
+
18
+ - update `Command`, support min/max input ranges ([471543e](https://github.com/thi-ng/umbrella/commit/471543e))
19
+ - update cliApp() input checks & error messages
20
+
14
21
  ### [2.7.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.7.1) (2025-07-11)
15
22
 
16
23
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -18,6 +18,7 @@
18
18
  - [Status](#status)
19
19
  - [Installation](#installation)
20
20
  - [Dependencies](#dependencies)
21
+ - [Projects using this package](#projects-using-this-package)
21
22
  - [API](#api)
22
23
  - [Basic usage](#basic-usage)
23
24
  - [Generate & display help](#generate--display-help)
@@ -71,7 +72,7 @@ For Node.js REPL:
71
72
  const args = await import("@thi.ng/args");
72
73
  ```
73
74
 
74
- Package sizes (brotli'd, pre-treeshake): ESM: 2.91 KB
75
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.99 KB
75
76
 
76
77
  ## Dependencies
77
78
 
@@ -84,6 +85,19 @@ Package sizes (brotli'd, pre-treeshake): ESM: 2.91 KB
84
85
 
85
86
  Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
86
87
 
88
+ ## Projects using this package
89
+
90
+ - [@thi.ng/block-fs](https://thi.ng/block-fs): Customizable block-based storage,
91
+ adapters & file system layer
92
+ - [@thi.ng/meta-css](https://thi.ng/meta-css): Data-driven CSS framework
93
+ codegen, transpiler & bundler
94
+ - [@thi.ng/pointfree-lang](https://thi.ng/pointfree-lang): Forth style syntax
95
+ layer/compiler & CLI for the [@thi.ng/pointfree](https://thi.ng/pointfree) DSL
96
+ - [@thi.ng/tangle](https://thi.ng/tangle): Literate programming code block
97
+ tangling / codegen utility, inspired by org-mode & noweb
98
+ - [@thi.ng/wasm-api-bindgen](https://thi.ng/wasm-api-bindgen): Polyglot bindings
99
+ code generators (TS/JS, Zig, C11) for hybrid WebAssembly projects
100
+
87
101
  ## API
88
102
 
89
103
  [Generated API docs](https://docs.thi.ng/umbrella/args/)
package/api.d.ts CHANGED
@@ -238,9 +238,10 @@ export interface Command<OPTS extends BASE, BASE extends object, CTX extends Com
238
238
  opts: Args<Omit<OPTS, keyof BASE>>;
239
239
  /**
240
240
  * Number of required rest input value (after all parsed options). Leave
241
- * unset to allow any number.
241
+ * unset to allow any number. If given as tuple, the values are interpreted
242
+ * as acceptable `[min,max]` range.
242
243
  */
243
- inputs?: number;
244
+ inputs?: number | [number, number];
244
245
  /**
245
246
  * Actual command function/implementation.
246
247
  */
package/cli.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  __padRightAnsi,
11
11
  __wrapWithIndent
12
12
  } from "./utils.js";
13
+ import { isArray } from "@thi.ng/checks/is-array";
13
14
  const cliApp = async (config) => {
14
15
  const argv = config.argv || process.argv;
15
16
  const isColor = !process.env.NO_COLOR;
@@ -46,9 +47,21 @@ const cliApp = async (config) => {
46
47
  process.exit(1);
47
48
  }
48
49
  if (!parsed) process.exit(0);
49
- if (cmd.inputs !== void 0 && cmd.inputs !== parsed.rest.length) {
50
- __printError(`expected ${cmd.inputs || 0} input(s)`, theme);
51
- __usageAndExit(config, usageOpts);
50
+ if (cmd.inputs !== void 0) {
51
+ const num = parsed.rest.length;
52
+ let err;
53
+ if (isArray(cmd.inputs)) {
54
+ const [min, max] = cmd.inputs;
55
+ if (num < min || num > max) {
56
+ err = max < Infinity ? `expected ${min}-${max} inputs` : `expected at least ${min} inputs`;
57
+ }
58
+ } else if (num !== cmd.inputs) {
59
+ err = `expected ${cmd.inputs} input(s)`;
60
+ }
61
+ if (err) {
62
+ __printError(err, theme);
63
+ __usageAndExit(config, usageOpts);
64
+ }
52
65
  }
53
66
  const ctx = await config.ctx(
54
67
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/args",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "Declarative, functional CLI argument/options parser, value coercions, sub-commands etc.",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -110,5 +110,5 @@
110
110
  "tag": "cli",
111
111
  "year": 2018
112
112
  },
113
- "gitHead": "cc6ab918acdac66990d04d6751d19c573a09730d\n"
113
+ "gitHead": "a157f18f16200faad01e15da553c9eea3fa37014\n"
114
114
  }