@procedures/cli-kit 0.0.0-stage → 0.35.1

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/dist/help.js ADDED
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The help text of a command line: the help of one command, of a group of commands and of the
3
+ * whole program.
4
+ *
5
+ * Each function gives the text and prints nothing. The caller prints it.
6
+ */
7
+ import { findChildren } from "./args.js";
8
+ import { extractSchemaFields, fieldWithoutSchema, toKebab, typeName, } from "./fields.js";
9
+ /** This function gives the hint of a field on the command line, for the help text. */
10
+ function valueHint(field) {
11
+ const type = field.fieldType;
12
+ switch (type.kind) {
13
+ case "boolean":
14
+ return "";
15
+ case "array":
16
+ return ` <${typeName(type.item ?? { kind: "any" })}>... (repeat the flag, or give a JSON array)`;
17
+ case "record":
18
+ return " <key=value>... (repeat the flag, or give a JSON object)";
19
+ case "object":
20
+ case "any":
21
+ return " <json>";
22
+ case "enum":
23
+ return ` <${(field.enumValues ?? []).join("|")}>`;
24
+ default:
25
+ return ` <${typeName(type)}>`;
26
+ }
27
+ }
28
+ /**
29
+ * This function gives the help text of one command. `schema` is the input schema, or the fields
30
+ * of the input. `result` gives the fields of the result. The help lists them after the options.
31
+ */
32
+ export function generateHelp(path, meta, schema, result, options) {
33
+ const positionalArgs = meta.args ?? [];
34
+ const shorts = meta.shorts ?? {};
35
+ const lines = [];
36
+ const schemaFields = Array.isArray(schema)
37
+ ? schema
38
+ : schema
39
+ ? extractSchemaFields(schema)
40
+ : [];
41
+ const schemaFieldMap = new Map(schemaFields.map((f) => [f.name, f]));
42
+ // Command signature: the last positional array takes the rest of the arguments
43
+ const cmdName = `${options.name} ${path.join(" ")}`;
44
+ const posStr = positionalArgs
45
+ .map((a, i) => {
46
+ const many = i === positionalArgs.length - 1 && schemaFieldMap.get(a)?.fieldType.kind === "array";
47
+ return many ? `<${a}...>` : `<${a}>`;
48
+ })
49
+ .join(" ");
50
+ lines.push(`Usage: ${cmdName}${posStr ? " " + posStr : ""} [options]`);
51
+ lines.push("");
52
+ if (meta.description) {
53
+ lines.push(meta.description);
54
+ lines.push("");
55
+ }
56
+ if (positionalArgs.length > 0) {
57
+ lines.push("Arguments:");
58
+ for (const arg of positionalArgs) {
59
+ const fieldInfo = schemaFieldMap.get(arg);
60
+ const typeStr = fieldInfo ? ` (${fieldInfo.type})` : "";
61
+ const reqStr = fieldInfo?.required ? " [required]" : "";
62
+ const descStr = fieldInfo?.description ? ` ${fieldInfo.description}` : "";
63
+ lines.push(` ${arg}${typeStr}${reqStr}`);
64
+ if (descStr) {
65
+ lines.push(` ${descStr}`);
66
+ }
67
+ }
68
+ lines.push("");
69
+ }
70
+ // Options: each schema field that is not positional, with its short flag if it has one
71
+ const optionLines = [];
72
+ const positionalSet = new Set(positionalArgs);
73
+ const listed = new Set();
74
+ const optionFields = [
75
+ ...Object.keys(shorts).map((name) => schemaFieldMap.get(name) ?? fieldWithoutSchema(name)),
76
+ ...schemaFields.filter((field) => !(field.name in shorts) && !positionalSet.has(field.name)),
77
+ ];
78
+ for (const field of optionFields) {
79
+ if (listed.has(field.name)) {
80
+ continue;
81
+ }
82
+ listed.add(field.name);
83
+ const short = shorts[field.name];
84
+ const kebab = toKebab(field.name);
85
+ const flag = short ? ` -${short}, --${kebab}` : ` --${kebab}`;
86
+ const negation = field.fieldType.kind === "boolean" ? ` (or --no-${kebab})` : "";
87
+ const reqStr = field.required ? " [required]" : "";
88
+ const defaultStr = field.defaultValue !== undefined ? ` (default: ${JSON.stringify(field.defaultValue)})` : "";
89
+ optionLines.push(`${flag}${valueHint(field)}${negation}${reqStr}${defaultStr}`);
90
+ if (field.description) {
91
+ optionLines.push(` ${field.description}`);
92
+ }
93
+ }
94
+ if (optionLines.length > 0) {
95
+ lines.push("Options:");
96
+ lines.push(...optionLines);
97
+ }
98
+ if (result.length > 0) {
99
+ lines.push("");
100
+ lines.push("Result:");
101
+ for (const field of result) {
102
+ const optional = field.required ? "" : ", optional";
103
+ lines.push(` ${field.name} (${field.type}${optional})`);
104
+ if (field.description) {
105
+ lines.push(` ${field.description}`);
106
+ }
107
+ }
108
+ }
109
+ const globals = (options.globals ?? []).filter((flag) => !flag.hidden);
110
+ if (globals.length > 0) {
111
+ lines.push("");
112
+ lines.push("Global Options (before the command, or after it when the command has no flag of that name):");
113
+ for (const flag of globals) {
114
+ const name = flag.short ? `-${flag.short}, --${flag.long}` : ` --${flag.long}`;
115
+ lines.push(` ${name.padEnd(18)} ${flag.description}`);
116
+ }
117
+ }
118
+ return lines.join("\n");
119
+ }
120
+ /**
121
+ * This function gives the help of a group of commands: one message for each line. It gives
122
+ * undefined when no command is in the group. A message can contain a line break.
123
+ */
124
+ export function groupHelp(name, commands, path) {
125
+ const children = findChildren(commands, path);
126
+ if (children.length === 0) {
127
+ return undefined;
128
+ }
129
+ const groupName = path.join(" ");
130
+ const lines = [`${groupName} commands:\n`];
131
+ // The commands directly in the group
132
+ for (const child of children.filter((p) => p.path.length === path.length + 1)) {
133
+ const meta = (child.metadata ?? {});
134
+ const cmdName = child.path[child.path.length - 1] ?? "";
135
+ lines.push(` ${name} ${groupName} ${cmdName} ${meta.description ?? ""}`);
136
+ }
137
+ // The groups in the group
138
+ const childGroups = new Set();
139
+ for (const child of children) {
140
+ if (child.path.length > path.length + 1) {
141
+ const groupSeg = child.path[path.length];
142
+ if (groupSeg)
143
+ childGroups.add(groupSeg);
144
+ }
145
+ }
146
+ for (const group of childGroups) {
147
+ lines.push(` ${name} ${groupName} ${group} ${group} commands`);
148
+ }
149
+ lines.push(`\nRun '${name} ${groupName} <command> --help' for more info.`);
150
+ return lines;
151
+ }
152
+ /**
153
+ * This function gives the help of the whole program: the commands by their first word. It gives
154
+ * one message for each line. A message can contain a line break.
155
+ */
156
+ export function rootHelp(commands, options) {
157
+ const { name } = options;
158
+ const lines = [`${options.title ?? name}\n`, "Commands:\n"];
159
+ const groups = new Map();
160
+ for (const proc of commands) {
161
+ const group = proc.path[0] ?? "other";
162
+ const members = groups.get(group) ?? [];
163
+ members.push(proc);
164
+ groups.set(group, members);
165
+ }
166
+ for (const [group, procs] of groups) {
167
+ lines.push(` ${group}`);
168
+ for (const proc of procs) {
169
+ const meta = (proc.metadata ?? {});
170
+ lines.push(` ${name} ${proc.path.join(" ")} ${meta.description ?? ""}`);
171
+ }
172
+ lines.push("");
173
+ }
174
+ lines.push(`Run '${name} <command> --help' for more information.`);
175
+ lines.push(...(options.footer ?? []));
176
+ return lines;
177
+ }
178
+ /** This function gives the message of a validation error: one line for each issue of a Zod error. */
179
+ export function validationMessage(error) {
180
+ const issues = error.issues;
181
+ if (Array.isArray(issues) && issues.length > 0) {
182
+ return issues
183
+ .map((issue) => `${(issue.path ?? []).join(".") || "input"}: ${issue.message ?? "invalid"}`)
184
+ .join("\n ");
185
+ }
186
+ return error instanceof Error ? error.message : String(error);
187
+ }
188
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,QAAQ,GAIT,MAAM,aAAa,CAAC;AAUrB,sFAAsF;AACtF,SAAS,SAAS,CAAC,KAAsB;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC;IAC7B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,8CAA8C,CAAC;QACnG,KAAK,QAAQ;YACX,OAAO,0DAA0D,CAAC;QACpE,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK;YACR,OAAO,SAAS,CAAC;QACnB,KAAK,MAAM;YACT,OA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C,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;aAC3F,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@procedures/cli-kit`: a command line for any procedure registry.
3
+ *
4
+ * The package has no procedures, and an import registers nothing. `createProcedureCli()` makes
5
+ * a whole program. The other exports are its parts: the parse, the help, the questions and the
6
+ * output. The `mark` CLI uses the parts.
7
+ */
8
+ export { createProcedureCli, STANDARD_GLOBAL_FLAGS, type CliCallOptions, type CliClient, type CommandSource, type FormatContext, type FormatHook, type ProcedureCli, type ProcedureCliOptions, type ProcedureCliRunOptions, } from "./cli.js";
9
+ export { findChildren, findGlobalFlag, findProcedure, parseCommandLine, parseLeadingGlobals, procedureFlags, type GlobalFlag, type Globals, type ParsedCommandLine, type ParseOptions, } from "./args.js";
10
+ export { convertValue, extractSchemaFields, fieldTypeOf, fieldsOf, mergeValue, resultFieldsOf, resultFieldsOfSchema, toCamel, toKebab, type CLIMeta, type CommandLike, type Converted, type FieldKind, type FieldType, type SchemaFieldInfo, } from "./fields.js";
11
+ export { generateHelp, groupHelp, rootHelp, validationMessage, type HelpOptions, type RootHelpOptions, } from "./help.js";
12
+ export { askMissing, canAsk, missingFields, processTerminal, questionOf, terminalAsker, type Answer, type Asked, type Asker, type Terminal, } from "./ask.js";
13
+ export { formatOutput, plainPrint, type OutputFormat, type Print, type Spinner } from "./format.js";
14
+ export { failureOf } from "./failure.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,OAAO,EACP,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,MAAM,EACN,aAAa,EACb,eAAe,EACf,UAAU,EACV,aAAa,EACb,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,KAAK,EACV,KAAK,QAAQ,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@procedures/cli-kit`: a command line for any procedure registry.
3
+ *
4
+ * The package has no procedures, and an import registers nothing. `createProcedureCli()` makes
5
+ * a whole program. The other exports are its parts: the parse, the help, the questions and the
6
+ * output. The `mark` CLI uses the parts.
7
+ */
8
+ export { createProcedureCli, STANDARD_GLOBAL_FLAGS, } from "./cli.js";
9
+ export { findChildren, findGlobalFlag, findProcedure, parseCommandLine, parseLeadingGlobals, procedureFlags, } from "./args.js";
10
+ export { convertValue, extractSchemaFields, fieldTypeOf, fieldsOf, mergeValue, resultFieldsOf, resultFieldsOfSchema, toCamel, toKebab, } from "./fields.js";
11
+ export { generateHelp, groupHelp, rootHelp, validationMessage, } from "./help.js";
12
+ export { askMissing, canAsk, missingFields, processTerminal, questionOf, terminalAsker, } from "./ask.js";
13
+ export { formatOutput, plainPrint } from "./format.js";
14
+ export { failureOf } from "./failure.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GAStB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,GAKf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,OAAO,GAOR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,iBAAiB,GAGlB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,MAAM,EACN,aAAa,EACb,eAAe,EACf,UAAU,EACV,aAAa,GAKd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,UAAU,EAA+C,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@procedures/cli-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
4
+ "version": "0.35.1",
5
+ "description": "A command line for any procedure registry: flags from the input schemas, help, --json, questions for missing arguments, @file input, short flags and a format hook for each procedure.",
6
+ "keywords": [
7
+ "cli",
8
+ "command-line",
9
+ "procedures",
10
+ "flags",
11
+ "help",
12
+ "zod"
13
+ ],
14
+ "homepage": "https://mark1russell7.github.io/client/",
15
+ "bugs": {
16
+ "url": "https://github.com/mark1russell7/client/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/mark1russell7/client.git",
21
+ "directory": "packages/cli-kit"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Mark Russell (https://github.com/mark1russell7)",
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "src",
37
+ "!src/**/*.test.ts",
38
+ "!src/**/*.test.tsx",
39
+ "!src/**/__tests__",
40
+ "CHANGELOG.md"
41
+ ],
42
+ "sideEffects": false,
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "provenance": true
49
+ },
50
+ "dependencies": {
51
+ "@clack/prompts": "^0.7.0",
52
+ "@procedures/client": "0.35.1"
53
+ },
54
+ "devDependencies": {
55
+ "typescript": "^7.0.2",
56
+ "@types/node": "^22.0.0",
57
+ "@mark1russell7/cue": "^1.0.0",
58
+ "vitest": "^5.0.3",
59
+ "zod": "^4.6.5"
60
+ },
61
+ "scripts": {
62
+ "build": "tsc -b",
63
+ "typecheck": "tsc --noEmit",
64
+ "clean": "rm -rf dist .tsbuildinfo",
65
+ "test": "vitest run",
66
+ "test:watch": "vitest"
67
+ }
6
68
  }