@thi.ng/args 2.0.8 → 2.1.3

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/CHANGELOG.md +122 -61
  2. package/package.json +93 -88
  3. package/tools/test.js +19 -0
package/CHANGELOG.md CHANGED
@@ -1,116 +1,177 @@
1
1
  # Change Log
2
2
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [2.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@2.0.7...@thi.ng/args@2.0.8) (2021-11-10)
7
-
8
- **Note:** Version bump only for package @thi.ng/args
9
-
3
+ - **Last updated**: 2021-11-21T17:09:28Z
4
+ - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
10
5
 
6
+ All notable changes to this project will be documented in this file.
7
+ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
11
8
 
9
+ **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
+ and/or version bumps of transitive dependencies.
12
11
 
12
+ ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.1.0) (2021-11-17)
13
13
 
14
- ## [2.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@2.0.6...@thi.ng/args@2.0.7) (2021-11-03)
14
+ #### 🚀 Features
15
15
 
16
- **Note:** Version bump only for package @thi.ng/args
16
+ - Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
17
+ Improving the overall build ergonomics
18
+ - introduced a tools workspaces
19
+ - imported it in all needed packages/examples
20
+ - inclusive project root
17
21
 
22
+ #### ♻️ Refactoring
18
23
 
24
+ - testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
25
+ this commit reverts (partly) changes made in:
26
+ ef346d7a8753590dc9094108a3d861a8dbd5dd2c
27
+ overall purpose is better testament ergonomics:
28
+ instead of having to pass NODE_OPTIONS with every invocation
29
+ having a binary to handle this for us.
19
30
 
31
+ ### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.0.1) (2021-10-13)
20
32
 
33
+ #### ♻️ Refactoring
21
34
 
22
- # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@1.1.1...@thi.ng/args@2.0.0) (2021-10-12)
35
+ - update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
36
+ - update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
37
+ - add .js suffix for all relative imports
23
38
 
39
+ # [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.0.0) (2021-10-12)
24
40
 
25
- ### Build System
41
+ #### 🛑 Breaking changes
26
42
 
27
- * major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
43
+ - major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
44
+ - BREAKING CHANGE: discontinue CommonJS & UMD versions
45
+ - only ESM modules will be published from now on
46
+ - CJS obsolete due to ESM support in recent versions of node:
47
+ - i.e. launch NodeJS via:
48
+ - `node --experimental-specifier-resolution=node --experimental-repl-await`
49
+ - in the node REPL use `await import(...)` instead of `require()`
50
+ - UMD obsolete due to widespread browser support for ESM
51
+ Also:
52
+ - normalize/restructure/reorg all package.json files
53
+ - cleanup all build scripts, remove obsolete
54
+ - switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
28
55
 
56
+ #### ♻️ Refactoring
29
57
 
30
- ### BREAKING CHANGES
58
+ - update imports ([890936b](https://github.com/thi-ng/umbrella/commit/890936b))
59
+ - update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
60
+ - update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
31
61
 
32
- * discontinue CommonJS & UMD versions
62
+ ### [1.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@1.1.1) (2021-09-03)
33
63
 
34
- - only ESM modules will be published from now on
35
- - CJS obsolete due to ESM support in recent versions of node:
36
- - i.e. launch NodeJS via:
37
- - `node --experimental-specifier-resolution=node --experimental-repl-await`
38
- - in the node REPL use `await import(...)` instead of `require()`
39
- - UMD obsolete due to widespread browser support for ESM
64
+ #### ♻️ Refactoring
40
65
 
41
- Also:
42
- - normalize/restructure/reorg all package.json files
43
- - cleanup all build scripts, remove obsolete
44
- - switch from mocha to @thi.ng/testament for all tests
66
+ - fix up TS4.4 changes ([ba616db](https://github.com/thi-ng/umbrella/commit/ba616db))
45
67
 
68
+ ## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@1.1.0) (2021-08-19)
46
69
 
70
+ #### 🚀 Features
47
71
 
72
+ - capitalize usage section headings ([eaa0f23](https://github.com/thi-ng/umbrella/commit/eaa0f23))
48
73
 
74
+ ### [0.7.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.7.1) (2021-07-29)
49
75
 
76
+ #### 🩹 Bug fixes
50
77
 
51
- # [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@1.0.4...@thi.ng/args@1.1.0) (2021-08-19)
78
+ - omit empty groups from usage() ([a66c19a](https://github.com/thi-ng/umbrella/commit/a66c19a))
52
79
 
53
- ### Features
80
+ ## [0.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.7.0) (2021-07-01)
54
81
 
55
- - **args:** capitalize usage section headings ([eaa0f23](https://github.com/thi-ng/umbrella/commit/eaa0f23a88cfb98da05b245b720a6fbb260ea7da))
82
+ #### 🚀 Features
56
83
 
57
- ## [0.7.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.7.0...@thi.ng/args@0.7.1) (2021-07-29)
84
+ - add showGroupNames option ([6917111](https://github.com/thi-ng/umbrella/commit/6917111))
58
85
 
59
- ### Bug Fixes
86
+ ## [0.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.6.0) (2021-06-08)
60
87
 
61
- - **args:** omit empty groups from usage() ([a66c19a](https://github.com/thi-ng/umbrella/commit/a66c19aa8d682a7f4b6ae5b3de51a26e806a02dc))
88
+ #### 🚀 Features
62
89
 
63
- # [0.7.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.6.0...@thi.ng/args@0.7.0) (2021-07-01)
90
+ - add kvPairsMulti(), update coerceKV() ([fd12f80](https://github.com/thi-ng/umbrella/commit/fd12f80))
91
+ - add KVMultiDict type alias
92
+ - update tests
64
93
 
65
- ### Features
94
+ ## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.5.0) (2021-03-28)
66
95
 
67
- - **args:** add showGroupNames option ([6917111](https://github.com/thi-ng/umbrella/commit/6917111aa6f019cbc4622a30be65c7f43cf995f9))
96
+ #### 🚀 Features
68
97
 
69
- # [0.6.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.5.1...@thi.ng/args@0.6.0) (2021-06-08)
98
+ - add vec() arg type ([f05cb2a](https://github.com/thi-ng/umbrella/commit/f05cb2a))
99
+ - wordwrap usage prefix/suffix, defaults ([325b558](https://github.com/thi-ng/umbrella/commit/325b558))
100
+ - update/revert default val handling in usage(), don't show null/false
101
+ - minor other usage() refactoring
102
+ - update doc strings
70
103
 
71
- ### Features
104
+ ### [0.4.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.4.1) (2021-03-24)
72
105
 
73
- - **args:** add kvPairsMulti(), update coerceKV() ([fd12f80](https://github.com/thi-ng/umbrella/commit/fd12f807dba2546133278a607c4b79dcf9a12b07))
106
+ #### ♻️ Refactoring
74
107
 
75
- # [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.4.2...@thi.ng/args@0.5.0) (2021-03-28)
108
+ - update wordwrapping in usage() ([4af3d41](https://github.com/thi-ng/umbrella/commit/4af3d41))
76
109
 
77
- ### Features
110
+ ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.4.0) (2021-03-22)
78
111
 
79
- - **args:** add vec() arg type ([f05cb2a](https://github.com/thi-ng/umbrella/commit/f05cb2a6d0798ef0558775a81dba2d834308747c))
80
- - **args:** wordwrap usage prefix/suffix, defaults ([325b558](https://github.com/thi-ng/umbrella/commit/325b558f74f8dbfaa2c7de72c6800cdbc8c54acd))
112
+ #### 🚀 Features
81
113
 
82
- # [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.3.1...@thi.ng/args@0.4.0) (2021-03-22)
114
+ - add arg groups, segment usage output ([ebf5197](https://github.com/thi-ng/umbrella/commit/ebf5197))
115
+ - add `ArgSpecBase.group` to classify args
116
+ - update arg factories to define default groups ("flags" & "main")
117
+ - update usage() to output segmented & sorted groups of args
118
+ - support arbitrary length aliases ([1cfdf49](https://github.com/thi-ng/umbrella/commit/1cfdf49))
119
+ - update parseKey() to allow any length aliases
120
+ - add test
83
121
 
84
- ### Features
122
+ ### [0.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.3.1) (2021-03-21)
85
123
 
86
- - **args:** add arg groups, segment usage output ([ebf5197](https://github.com/thi-ng/umbrella/commit/ebf51974e4e1e1d5288af9ad420d4211addd95ad))
87
- - **args:** support arbitrary length aliases ([1cfdf49](https://github.com/thi-ng/umbrella/commit/1cfdf49a53cca2f80836caf428e220e90f687ad1))
124
+ #### 🩹 Bug fixes
88
125
 
89
- ## [0.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.3.0...@thi.ng/args@0.3.1) (2021-03-21)
126
+ - fix usage() show defaults logic ([ae31158](https://github.com/thi-ng/umbrella/commit/ae31158))
127
+ - show all default values (incl. zero, false), only skip undefined
90
128
 
91
- ### Bug Fixes
129
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.3.0) (2021-03-20)
92
130
 
93
- - **args:** fix usage() show defaults logic ([ae31158](https://github.com/thi-ng/umbrella/commit/ae31158c9496d7c116ee2b4a22ca843888d2bddd))
131
+ #### 🚀 Features
94
132
 
95
- # [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.2.7...@thi.ng/args@0.3.0) (2021-03-20)
133
+ - update ParseOpts, UsageOpts ([6577c80](https://github.com/thi-ng/umbrella/commit/6577c80))
134
+ - add `ParseOpts.help` to configure special `--help` option(s)
135
+ - add `UsageOpts.prefix/suffix` strings
96
136
 
97
- ### Features
137
+ ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.2.0) (2021-01-13)
98
138
 
99
- - **args:** update ParseOpts, UsageOpts ([6577c80](https://github.com/thi-ng/umbrella/commit/6577c806e246ecf8244b1af6a2cefc400a7eb365))
139
+ #### 🚀 Features
100
140
 
101
- # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.1.0...@thi.ng/args@0.2.0) (2021-01-13)
141
+ - add defaultHint opt, update usage() ([f8a4146](https://github.com/thi-ng/umbrella/commit/f8a4146))
142
+ - add UsageOpts.showDefaults to display arg default vals
143
+ - add ArgSpecBase.defaultHint for default vals for display purposes
102
144
 
103
- ### Features
145
+ #### ♻️ Refactoring
104
146
 
105
- - **args:** add defaultHint opt, update usage() ([f8a4146](https://github.com/thi-ng/umbrella/commit/f8a414605a0d5c93fcef83ab931911c6c2f39f7d))
147
+ - splitup parse() into smaller fns ([64be608](https://github.com/thi-ng/umbrella/commit/64be608))
106
148
 
107
- # 0.1.0 (2021-01-10)
149
+ ## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@0.1.0) (2021-01-10)
108
150
 
109
- ### Features
151
+ #### 🚀 Features
110
152
 
111
- - **args:** add kv args, callbacks, usage opts ([c306aba](https://github.com/thi-ng/umbrella/commit/c306abac31dc03bb15a19c36192ee5c07afa1063))
112
- - **args:** add strict mode kvArgs()/coerceKV(), add docs ([b76c4f1](https://github.com/thi-ng/umbrella/commit/b76c4f11ddbe3b7c1a195a93ceed3a953666ef5d))
113
- - **args:** add tuple arg type support ([a05dde9](https://github.com/thi-ng/umbrella/commit/a05dde957be54ae7ed6aeab8233bff0d8573c675))
114
- - **args:** import as new package ([af5d943](https://github.com/thi-ng/umbrella/commit/af5d943153b3012be04ed0e9a044ee944465d035))
115
- - **args:** major general package update ([26ec49a](https://github.com/thi-ng/umbrella/commit/26ec49afc0fa389b7a2551b116a85d95df4aaeee))
116
- - **args:** update multi arg specs, parse ([dbdf913](https://github.com/thi-ng/umbrella/commit/dbdf913b4ed730c2c07246c24ecbafb32d9dc37e))
153
+ - add tuple arg type support ([a05dde9](https://github.com/thi-ng/umbrella/commit/a05dde9))
154
+ - update multi arg specs, parse ([dbdf913](https://github.com/thi-ng/umbrella/commit/dbdf913))
155
+ - simplify Args conditionals (remove special casing for string(s))
156
+ - replace spec.comma => spec.delim
157
+ - update ParseResult
158
+ - update parse() to stop at first non-arg value
159
+ - add/update tests
160
+ - add strict mode kvArgs()/coerceKV(), add docs ([b76c4f1](https://github.com/thi-ng/umbrella/commit/b76c4f1))
161
+ - add kv args, callbacks, usage opts ([c306aba](https://github.com/thi-ng/umbrella/commit/c306aba))
162
+ - add KVDict type, coerceKV(), kvPairs()
163
+ - add optional `fn` arg spec callbacks
164
+ - add `--help` built-in handling
165
+ - add ColorTheme, update usage()
166
+ - major general package update ([26ec49a](https://github.com/thi-ng/umbrella/commit/26ec49a))
167
+ - use more mapped types to better infer & verify specs for optional args
168
+ - add support for comma separated multi-args
169
+ - add ParseOpts & UsageOpts
170
+ - add/replace coercions
171
+ - add arg spec factories
172
+ - update parse()
173
+ - add comma handling
174
+ - auto-usage on error
175
+ - kebab -> camelCase names
176
+ - update/rewrite usage(), add color support
177
+ - import as new package ([af5d943](https://github.com/thi-ng/umbrella/commit/af5d943))
package/package.json CHANGED
@@ -1,95 +1,100 @@
1
1
  {
2
- "name": "@thi.ng/args",
3
- "version": "2.0.8",
4
- "description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.",
5
- "type": "module",
6
- "module": "./index.js",
7
- "typings": "./index.d.ts",
8
- "sideEffects": false,
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/thi-ng/umbrella.git"
2
+ "name": "@thi.ng/args",
3
+ "version": "2.1.3",
4
+ "description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.",
5
+ "type": "module",
6
+ "module": "./index.js",
7
+ "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/thi-ng/umbrella.git"
12
+ },
13
+ "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/args#readme",
14
+ "funding": [
15
+ {
16
+ "type": "github",
17
+ "url": "https://github.com/sponsors/postspectacular"
12
18
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/args#readme",
14
- "funding": [
15
- {
16
- "type": "github",
17
- "url": "https://github.com/sponsors/postspectacular"
18
- },
19
- {
20
- "type": "patreon",
21
- "url": "https://patreon.com/thing_umbrella"
22
- }
23
- ],
24
- "author": "Karsten Schmidt <k+npm@thi.ng>",
25
- "license": "Apache-2.0",
26
- "scripts": {
27
- "build": "yarn clean && tsc --declaration",
28
- "clean": "rimraf *.js *.d.ts *.map doc",
29
- "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
- "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
31
- "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
- "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
- "pub": "yarn build && yarn publish --access public",
34
- "test": "testament test"
19
+ {
20
+ "type": "patreon",
21
+ "url": "https://patreon.com/thing_umbrella"
22
+ }
23
+ ],
24
+ "author": "Karsten Schmidt <k+npm@thi.ng>",
25
+ "license": "Apache-2.0",
26
+ "scripts": {
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
+ "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
31
+ "doc:readme": "yarn doc:stats && tools:readme",
32
+ "doc:stats": "tools:module-stats",
33
+ "pub": "yarn npm publish --access public",
34
+ "test": "testament test"
35
+ },
36
+ "dependencies": {
37
+ "@thi.ng/api": "^8.3.2",
38
+ "@thi.ng/checks": "^3.1.2",
39
+ "@thi.ng/errors": "^2.1.2",
40
+ "@thi.ng/strings": "^3.3.0"
41
+ },
42
+ "devDependencies": {
43
+ "@microsoft/api-extractor": "^7.18.19",
44
+ "@thi.ng/testament": "^0.2.2",
45
+ "rimraf": "^3.0.2",
46
+ "tools": "^0.0.1",
47
+ "typedoc": "^0.22.9",
48
+ "typescript": "^4.5.2"
49
+ },
50
+ "keywords": [
51
+ "argument",
52
+ "ansi",
53
+ "cli",
54
+ "coerce",
55
+ "color",
56
+ "conversion",
57
+ "declarative",
58
+ "functional",
59
+ "hex",
60
+ "node",
61
+ "parser",
62
+ "tuple",
63
+ "typescript",
64
+ "validate"
65
+ ],
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "engines": {
70
+ "node": ">=12.7"
71
+ },
72
+ "files": [
73
+ "*.js",
74
+ "*.d.ts"
75
+ ],
76
+ "exports": {
77
+ ".": {
78
+ "import": "./index.js"
35
79
  },
36
- "dependencies": {
37
- "@thi.ng/api": "^8.2.0",
38
- "@thi.ng/checks": "^3.0.7",
39
- "@thi.ng/errors": "^2.0.6",
40
- "@thi.ng/strings": "^3.1.4"
80
+ "./api": {
81
+ "import": "./api.js"
41
82
  },
42
- "devDependencies": {
43
- "@thi.ng/testament": "^0.1.6"
83
+ "./args": {
84
+ "import": "./args.js"
44
85
  },
45
- "keywords": [
46
- "argument",
47
- "ansi",
48
- "cli",
49
- "coerce",
50
- "color",
51
- "conversion",
52
- "declarative",
53
- "functional",
54
- "hex",
55
- "node",
56
- "parser",
57
- "tuple",
58
- "typescript",
59
- "validate"
60
- ],
61
- "publishConfig": {
62
- "access": "public"
86
+ "./coerce": {
87
+ "import": "./coerce.js"
63
88
  },
64
- "engines": {
65
- "node": ">=12.7"
89
+ "./parse": {
90
+ "import": "./parse.js"
66
91
  },
67
- "files": [
68
- "*.js",
69
- "*.d.ts"
70
- ],
71
- "exports": {
72
- ".": {
73
- "import": "./index.js"
74
- },
75
- "./api": {
76
- "import": "./api.js"
77
- },
78
- "./args": {
79
- "import": "./args.js"
80
- },
81
- "./coerce": {
82
- "import": "./coerce.js"
83
- },
84
- "./parse": {
85
- "import": "./parse.js"
86
- },
87
- "./usage": {
88
- "import": "./usage.js"
89
- }
90
- },
91
- "thi.ng": {
92
- "year": 2018
93
- },
94
- "gitHead": "5fe52419af63984ebe53032201b2a6174b9cb159"
95
- }
92
+ "./usage": {
93
+ "import": "./usage.js"
94
+ }
95
+ },
96
+ "thi.ng": {
97
+ "year": 2018
98
+ },
99
+ "gitHead": "32cf1a96854f9bb97aca65ffa05ca862ea377059\n"
100
+ }
package/tools/test.js ADDED
@@ -0,0 +1,19 @@
1
+ const args = require("@thi.ng/args");
2
+ const { argFlag } = require("@thi.ng/args");
3
+
4
+ const opts = args.parse(
5
+ {
6
+ help: {
7
+ coerce: () => {
8
+ throw new Error();
9
+ },
10
+ flag: true,
11
+ desc: "Show this help",
12
+ },
13
+ optimize: argFlag({ alias: "o", desc: "optimize", default: false }),
14
+ minify: argFlag({ alias: "m", desc: "minify", default: false }),
15
+ },
16
+ process.argv
17
+ );
18
+
19
+ console.log(opts);