@thi.ng/args 2.8.6 → 2.9.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-08-04T09:13:01Z
3
+ - **Last updated**: 2025-08-06T18:02: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.
@@ -11,6 +11,16 @@ 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.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.9.0) (2025-08-06)
15
+
16
+ #### 🚀 Features
17
+
18
+ - add arg preset specs ([2b13af5](https://github.com/thi-ng/umbrella/commit/2b13af5))
19
+ - add ARG_DRY_RUN
20
+ - add ARG_QUIET, ARG_VERBOSE
21
+ - add ARG_OUT_DIR, ARG_OUT_FILE
22
+ - add configureLogLevel() ([ea5c6e4](https://github.com/thi-ng/umbrella/commit/ea5c6e4))
23
+
14
24
  ## [2.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.8.0) (2025-07-12)
15
25
 
16
26
  #### 🚀 Features
package/README.md CHANGED
@@ -72,7 +72,7 @@ For Node.js REPL:
72
72
  const args = await import("@thi.ng/args");
73
73
  ```
74
74
 
75
- Package sizes (brotli'd, pre-treeshake): ESM: 3.06 KB
75
+ Package sizes (brotli'd, pre-treeshake): ESM: 3.29 KB
76
76
 
77
77
  ## Dependencies
78
78
 
package/args.d.ts CHANGED
@@ -249,4 +249,74 @@ export declare const vec: <S extends Partial<ArgSpec<Tuple<number>>>>(size: numb
249
249
  hint: string;
250
250
  group: string;
251
251
  };
252
+ /**
253
+ * Re-usable preset arg spec for a `--dry-run` flag.
254
+ */
255
+ export declare const ARG_DRY_RUN: {
256
+ dryRun: {
257
+ desc: string;
258
+ } & {
259
+ flag: true;
260
+ default: boolean;
261
+ group: string;
262
+ };
263
+ };
264
+ /**
265
+ * Re-usable preset arg spec for a `--quiet` / `-q` flag.
266
+ */
267
+ export declare const ARG_QUIET: {
268
+ quiet: {
269
+ alias: string;
270
+ desc: string;
271
+ } & {
272
+ flag: true;
273
+ default: boolean;
274
+ group: string;
275
+ };
276
+ };
277
+ /**
278
+ * Re-usable preset arg spec for a `--verbose` / `-v` flag.
279
+ */
280
+ export declare const ARG_VERBOSE: {
281
+ verbose: {
282
+ alias: string;
283
+ desc: string;
284
+ } & {
285
+ flag: true;
286
+ default: boolean;
287
+ group: string;
288
+ };
289
+ };
290
+ /**
291
+ * Higher-order re-usable preset arg spec for a `--out-dir` / `-O` arg. Accepts
292
+ * optional default value (e.g. sourced from an env var). If the the
293
+ * `defaultVal` is defined, the arg is declared as optional, otherwise
294
+ * mandatory.
295
+ *
296
+ * @param defaultVal
297
+ * @param desc
298
+ */
299
+ export declare const ARG_OUT_DIR: <T extends string | undefined>(defaultVal?: string, desc?: string) => {
300
+ outDir: ReturnType<typeof string> & (T extends string ? {
301
+ default: string;
302
+ } : {
303
+ optional: false;
304
+ });
305
+ };
306
+ /**
307
+ * Higher-order re-usable preset arg spec for a `--out-file` / `-o` arg. Accepts
308
+ * optional default value (e.g. sourced from an env var). If the the
309
+ * `defaultVal` is defined, the arg is declared as optional, otherwise
310
+ * mandatory.
311
+ *
312
+ * @param defaultVal
313
+ * @param desc
314
+ */
315
+ export declare const ARG_OUT_FILE: <T extends string | undefined>(defaultVal?: T, desc?: string) => {
316
+ outFile: ReturnType<typeof string> & (T extends string ? {
317
+ default: string;
318
+ } : {
319
+ optional: false;
320
+ });
321
+ };
252
322
  //# sourceMappingURL=args.d.ts.map
package/args.js CHANGED
@@ -84,7 +84,47 @@ const tuple = (coerce, size2, spec, delim = ",") => ({
84
84
  });
85
85
  const size = (size2, spec, delim = "x") => tuple(coerceInt, size2, spec, delim);
86
86
  const vec = (size2, spec, delim = ",") => tuple(coerceFloat, size2, spec, delim);
87
+ const ARG_DRY_RUN = {
88
+ dryRun: flag({
89
+ desc: "Dry run (no changes applied)"
90
+ })
91
+ };
92
+ const ARG_QUIET = {
93
+ quiet: flag({
94
+ alias: "q",
95
+ desc: "Disable all logging"
96
+ })
97
+ };
98
+ const ARG_VERBOSE = {
99
+ verbose: flag({
100
+ alias: "v",
101
+ desc: "Display extra information"
102
+ })
103
+ };
104
+ const ARG_OUT_DIR = (defaultVal, desc) => ({
105
+ outDir: string({
106
+ alias: "O",
107
+ desc: "Output directory" + (desc ?? ""),
108
+ hint: "PATH",
109
+ default: defaultVal,
110
+ optional: !!defaultVal
111
+ })
112
+ });
113
+ const ARG_OUT_FILE = (defaultVal, desc) => ({
114
+ outFile: string({
115
+ alias: "o",
116
+ desc: "Output file" + (desc ?? ""),
117
+ hint: "PATH",
118
+ default: defaultVal,
119
+ optional: !!defaultVal
120
+ })
121
+ });
87
122
  export {
123
+ ARG_DRY_RUN,
124
+ ARG_OUT_DIR,
125
+ ARG_OUT_FILE,
126
+ ARG_QUIET,
127
+ ARG_VERBOSE,
88
128
  flag,
89
129
  float,
90
130
  floats,
package/cli.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type ILogger } from "@thi.ng/logger/api";
1
2
  import type { CLIAppConfig, CommandCtx } from "./api.js";
2
3
  export declare const cliApp: <OPTS extends object, CTX extends CommandCtx<OPTS, OPTS>>(config: CLIAppConfig<OPTS, CTX>) => Promise<void>;
3
4
  /**
@@ -7,4 +8,5 @@ export declare const cliApp: <OPTS extends object, CTX extends CommandCtx<OPTS,
7
8
  * @param fallback
8
9
  */
9
10
  export declare const terminalLineWidth: (fallback?: number) => number;
11
+ export declare const configureLogLevel: (logger: ILogger, verbose: boolean, quiet?: boolean) => void;
10
12
  //# sourceMappingURL=cli.d.ts.map
package/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isArray } from "@thi.ng/checks/is-array";
2
2
  import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
3
+ import { LogLevel } from "@thi.ng/logger/api";
3
4
  import { StreamLogger } from "@thi.ng/logger/stream";
4
5
  import { PRESET_ANSI16, PRESET_NONE } from "@thi.ng/text-format/presets";
5
6
  import { execFileSync } from "node:child_process";
@@ -110,7 +111,12 @@ const terminalLineWidth = (fallback = 80) => {
110
111
  return fallback;
111
112
  }
112
113
  };
114
+ const configureLogLevel = (logger, verbose, quiet = false) => {
115
+ if (quiet) logger.level = LogLevel.NONE;
116
+ else if (verbose) logger.level = LogLevel.DEBUG;
117
+ };
113
118
  export {
114
119
  cliApp,
120
+ configureLogLevel,
115
121
  terminalLineWidth
116
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/args",
3
- "version": "2.8.6",
3
+ "version": "2.9.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": "0bcedf8d1dd4f30cd06bb2c668599628f2f0141e\n"
113
+ "gitHead": "03e0d1024805407fbec5dde688b6178bbe0a2f3a\n"
114
114
  }