@dbx-tools/cli-args 0.9.58 → 0.9.60
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/README.md +27 -21
- package/exports.ts +1 -0
- package/index.ts +2 -1
- package/lib/exports.d.ts +1 -0
- package/lib/exports.js +2 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
# @dbx-tools/cli-args
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Generate Commander flags from a Zod object schema so any CLI can share one
|
|
4
|
+
argument, help, and layered-config path without installing the full `dbx`
|
|
5
|
+
package.
|
|
5
6
|
|
|
6
|
-
## Bind
|
|
7
|
+
## Bind And Parse Arguments
|
|
7
8
|
|
|
8
9
|
```ts
|
|
9
|
-
import { addArgs, parseArgs } from "@dbx-tools/cli-args
|
|
10
|
+
import { addArgs, parseArgs } from "@dbx-tools/cli-args";
|
|
10
11
|
import { Command } from "commander";
|
|
11
12
|
import { z } from "zod";
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const OptionsSchema = z.object({
|
|
14
15
|
port: z.coerce.number().default(3000).describe("Server listening port"),
|
|
15
|
-
|
|
16
|
+
databaseUrl: z.string().url().describe("PostgreSQL connection string"),
|
|
16
17
|
});
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
process.stdout.write(`${JSON.stringify(config)}\n`);
|
|
22
|
-
});
|
|
19
|
+
const program = addArgs(new Command("demo"), OptionsSchema);
|
|
20
|
+
await program.parseAsync(process.argv);
|
|
21
|
+
const options = parseArgs(program, OptionsSchema);
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
Help defaults come from Zod and from layered `@dbx-tools/core` configuration
|
|
25
|
+
(environment, `.env`, bundle, and app YAML). Use `.meta({ env, flag, helpDefault })`
|
|
26
|
+
when a field needs an exact environment name, should stay off the flag list, or
|
|
27
|
+
should hide its default.
|
|
28
|
+
|
|
29
|
+
## Serialize Options Back To Argv
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
```ts
|
|
32
|
+
import { serializeArgs } from "@dbx-tools/cli-args";
|
|
33
|
+
|
|
34
|
+
const argv = serializeArgs(OptionsSchema);
|
|
35
|
+
const fromValues = serializeArgs({ port: 8080, debug: false });
|
|
36
|
+
```
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
Schemas serialize their parsed defaults. Concrete objects serialize current
|
|
39
|
+
values. Boolean false becomes `--no-*`, arrays become repeated flags, and
|
|
40
|
+
listener addresses use the shared listen-address format.
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
repeated flags, and listener addresses become `host:port`.
|
|
42
|
+
Consuming commands own their schemas. This package only binds Commander, help,
|
|
43
|
+
and argv serialization.
|
package/exports.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addArgs, parseArgs, serializeArgs } from "./src/args.ts";
|
package/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/cli-args";
|
|
6
|
-
export const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.60";
|
|
7
7
|
export * as args from "./src/args.ts";
|
|
8
8
|
export type { CliArgsOptions, CliArgMeta, ArgumentSource } from "./src/args.ts";
|
|
9
|
+
export * from "./exports.ts";
|
package/lib/exports.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addArgs, parseArgs, serializeArgs } from "./src/args.ts";
|
package/lib/exports.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { addArgs, parseArgs, serializeArgs } from "./src/args.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwb3J0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL2V4cG9ydHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxTQUFTLEVBQUUsYUFBYSxFQUFFLE1BQU0sZUFBZSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgYWRkQXJncywgcGFyc2VBcmdzLCBzZXJpYWxpemVBcmdzIH0gZnJvbSBcIi4vc3JjL2FyZ3MudHNcIjtcbiJdfQ==
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const PACKAGE_IDENTIFIER = "@dbx-tools/cli-args";
|
|
2
|
-
export declare const PACKAGE_VERSION = "0.9.
|
|
2
|
+
export declare const PACKAGE_VERSION = "0.9.60";
|
|
3
3
|
export * as args from "./src/args.ts";
|
|
4
4
|
export type { CliArgsOptions, CliArgMeta, ArgumentSource } from "./src/args.ts";
|
|
5
|
+
export * from "./exports.ts";
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/cli-args";
|
|
5
|
-
export const PACKAGE_VERSION = "0.9.
|
|
5
|
+
export const PACKAGE_VERSION = "0.9.60";
|
|
6
6
|
export * as args from "./src/args.js";
|
|
7
|
-
|
|
7
|
+
export * from "./exports.js";
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRyxxQkFBcUIsQ0FBQztBQUN4RCxNQUFNLENBQUMsTUFBTSxlQUFlLEdBQUcsUUFBUSxDQUFDO0FBQ3hDLE9BQU8sS0FBSyxJQUFJLE1BQU0sZUFBZSxDQUFDO0FBRXRDLGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLy8gR0VORVJBVEVEIGJ5IHByb2plbiB3YXRjaCAtIERPIE5PVCBFRElULlxuLy8gUmVnZW5lcmF0ZWQgZnJvbSB0aGUgZXhwb3J0aW5nIG1vZHVsZXMgaW4gLi9zcmMuXG4vLyBIYW5kIGVkaXRzIGFyZSBvdmVyd3JpdHRlbiBvbiB0aGUgbmV4dCB3YXRjaDsgdGhpcyBmaWxlIGlzIHJlYWQtb25seS5cblxuZXhwb3J0IGNvbnN0IFBBQ0tBR0VfSURFTlRJRklFUiA9IFwiQGRieC10b29scy9jbGktYXJnc1wiO1xuZXhwb3J0IGNvbnN0IFBBQ0tBR0VfVkVSU0lPTiA9IFwiMC45LjYwXCI7XG5leHBvcnQgKiBhcyBhcmdzIGZyb20gXCIuL3NyYy9hcmdzLnRzXCI7XG5leHBvcnQgdHlwZSB7IENsaUFyZ3NPcHRpb25zLCBDbGlBcmdNZXRhLCBBcmd1bWVudFNvdXJjZSB9IGZyb20gXCIuL3NyYy9hcmdzLnRzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9leHBvcnRzLnRzXCI7XG4iXX0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbx-tools/cli-args",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Commander argument generation from Zod object schemas for dbx-tools CLIs",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/reggie-db/dbx-tools.git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"typescript": "^5.9.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dbx-tools/core": "^0.9.
|
|
27
|
-
"@dbx-tools/shared-core": "^0.9.
|
|
26
|
+
"@dbx-tools/core": "^0.9.60",
|
|
27
|
+
"@dbx-tools/shared-core": "^0.9.60",
|
|
28
28
|
"commander": "^15.0.0",
|
|
29
29
|
"zod": "4.3.6"
|
|
30
30
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
"version": "0.9.
|
|
49
|
+
"version": "0.9.60",
|
|
50
50
|
"types": "./lib/index.d.ts",
|
|
51
51
|
"dbxToolsConfig": {
|
|
52
52
|
"tags": [
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"files": [
|
|
69
69
|
"index.ts",
|
|
70
70
|
"src",
|
|
71
|
+
"exports.ts",
|
|
71
72
|
"bin",
|
|
72
73
|
"lib"
|
|
73
74
|
],
|