@zinn-dev/cli 0.46.0 → 0.47.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/package.json +2 -2
- package/skills/zinn/SKILL.md +1 -1
- package/src/capabilities-schema.d.ts +74 -0
- package/src/capabilities-schema.js +44 -0
- package/src/capabilities.d.ts +2 -0
- package/src/capabilities.js +2 -0
- package/src/column-hint.js +2 -9
- package/src/errors.d.ts +1 -0
- package/src/errors.js +1 -0
- package/src/input.d.ts +30 -0
- package/src/input.js +18 -0
- package/src/lib.d.ts +73 -5
- package/src/lib.js +69 -13
- package/src/presentation/activity-presentation.d.ts +2 -1
- package/src/presentation/activity-presentation.js +21 -6
- package/src/presentation/color.d.ts +12 -0
- package/src/presentation/color.js +12 -0
- package/src/presentation/project-presentation.d.ts +4 -1
- package/src/presentation/project-presentation.js +18 -0
- package/src/presentation/relation-presentation.js +8 -20
- package/src/presentation/section.d.ts +7 -4
- package/src/presentation/section.js +21 -7
- package/src/presentation/task-blame-presentation.d.ts +2 -1
- package/src/presentation/task-blame-presentation.js +4 -4
- package/src/presentation/task-presentation.d.ts +12 -1
- package/src/presentation/task-presentation.js +60 -9
- package/src/result-schemas.d.ts +93 -14
- package/src/result-schemas.js +1 -0
- package/src/routes/activity-router.d.ts +1 -1
- package/src/routes/activity-router.js +15 -31
- package/src/routes/backup-router.js +2 -9
- package/src/routes/capabilities-router.js +2 -9
- package/src/routes/comment-router.d.ts +2 -6
- package/src/routes/comment-router.js +13 -61
- package/src/routes/doctor-router.js +2 -9
- package/src/routes/info-router.js +2 -9
- package/src/routes/label-router.js +6 -43
- package/src/routes/migrate-router.js +2 -9
- package/src/routes/project-router.js +14 -100
- package/src/routes/reindex-router.js +2 -9
- package/src/routes/relation-router.d.ts +10 -4
- package/src/routes/relation-router.js +7 -18
- package/src/routes/restore-router.js +2 -11
- package/src/routes/router.js +32 -11
- package/src/routes/routes.d.ts +29 -30
- package/src/routes/skill-router.js +3 -18
- package/src/routes/task-router.d.ts +28 -28
- package/src/routes/task-router.js +62 -195
- package/src/routes/whoami-router.js +2 -9
- package/src/telemetry.js +3 -4
- package/src/types.d.ts +5 -1
- package/src/views.d.ts +117 -0
- package/src/views.js +54 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
|
|
2
2
|
import { jsonResult } from "../results.js";
|
|
3
|
-
import { parseArgs } from "node:util";
|
|
4
3
|
import { activity, activityActionSchema, activityChangedFieldSchema, activityChangedFieldsWithOptionalValue, activityChangedFieldsWithoutValue, activityChangedSchema, activityIdSchema, activityListSchema, CoreError, InputValidationError, readSnapshot, } from "@zinn-dev/core";
|
|
5
4
|
import { generateCommandUsage, getOptionInputs, violatesConstraint } from "../input.js";
|
|
6
5
|
import { CliError } from "../errors.js";
|
|
7
6
|
import { parseTimestampInput } from "../timestamp-input.js";
|
|
8
7
|
import { formatListContinuation } from "../list-continuation.js";
|
|
9
|
-
import { diagnostic, getOutputMode, output, outputStream, quit,
|
|
8
|
+
import { diagnostic, getOutputMode, output, outputStream, quit, parseCommandArgs } from "../lib.js";
|
|
10
9
|
import { followUntilStopped } from "../follow.js";
|
|
11
10
|
import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
|
|
11
|
+
import { readTerminalProps } from "../presentation/color.js";
|
|
12
12
|
const changedFieldList = activityChangedFieldSchema.options.join(", ");
|
|
13
13
|
const changedFieldListFormatter = new Intl.ListFormat("en-GB");
|
|
14
14
|
const changedFieldsWithoutValue = changedFieldListFormatter.format(activityChangedFieldsWithoutValue);
|
|
@@ -122,15 +122,7 @@ export const activityRouter = {
|
|
|
122
122
|
jsonResult("Activity", { kind: "booleanOption", name: "follow", value: true }, "json-lines"),
|
|
123
123
|
],
|
|
124
124
|
run: (args) => {
|
|
125
|
-
const { values,
|
|
126
|
-
args,
|
|
127
|
-
options: activityInputs.list.options,
|
|
128
|
-
allowPositionals: true,
|
|
129
|
-
strict: true,
|
|
130
|
-
tokens: true,
|
|
131
|
-
});
|
|
132
|
-
validateUniqueOptions(tokens, activityInputs.list.options);
|
|
133
|
-
validatePositionals(positionals, activityInputs.list.forms[0]);
|
|
125
|
+
const { values, tokens } = parseCommandArgs(args, activityInputs.list);
|
|
134
126
|
const [selectorConstraint, deletedHistoryConstraint, ...followConstraints] = activityInputs.list.constraints;
|
|
135
127
|
const optionInputs = getOptionInputs(values);
|
|
136
128
|
if (violatesConstraint(selectorConstraint, optionInputs)) {
|
|
@@ -176,15 +168,15 @@ export const activityRouter = {
|
|
|
176
168
|
since: parseTimestampInput(values.since, "--since"),
|
|
177
169
|
until: parseTimestampInput(values.until, "--until"),
|
|
178
170
|
};
|
|
179
|
-
const
|
|
171
|
+
const presentEvents = (events) => getOutputMode() === "json"
|
|
172
|
+
? { events: activity.attachTaskKeys(events), presented: [] }
|
|
173
|
+
: { events, presented: presentActivities(events, selection) };
|
|
180
174
|
if (values.follow === true) {
|
|
181
175
|
const follower = readSelectedActivity(values, () => activity.follow(filters));
|
|
182
176
|
return followUntilStopped(async (signal) => {
|
|
183
177
|
const polled = readSelectedActivity(values, () => readSnapshot(() => {
|
|
184
178
|
const polled = follower.poll();
|
|
185
|
-
return "stopped" in polled
|
|
186
|
-
? polled
|
|
187
|
-
: { ...polled, presented: presentTextEvents(polled.events) };
|
|
179
|
+
return "stopped" in polled ? polled : presentEvents(polled.events);
|
|
188
180
|
}));
|
|
189
181
|
if ("stopped" in polled) {
|
|
190
182
|
const reason = polled.stopped === "file_replaced"
|
|
@@ -198,7 +190,7 @@ export const activityRouter = {
|
|
|
198
190
|
const input = { ...filters, limit, startingAfter: values["starting-after"] };
|
|
199
191
|
const page = readSelectedActivity(values, () => readWithActivityPresentation(activityListSchema, input, () => {
|
|
200
192
|
const page = activity.getAll(input);
|
|
201
|
-
return { ...page,
|
|
193
|
+
return { ...page, ...presentEvents(page.events) };
|
|
202
194
|
}));
|
|
203
195
|
output(page.events, () => formatActivityList(page.presented));
|
|
204
196
|
if (page.nextCursor !== undefined) {
|
|
@@ -280,20 +272,15 @@ Examples:
|
|
|
280
272
|
input: activityInputs.view,
|
|
281
273
|
results: [jsonResult("Activity")],
|
|
282
274
|
run: (args) => {
|
|
283
|
-
const { positionals } =
|
|
284
|
-
options: activityInputs.view.options,
|
|
285
|
-
args,
|
|
286
|
-
allowPositionals: true,
|
|
287
|
-
strict: true,
|
|
288
|
-
});
|
|
289
|
-
validatePositionals(positionals, activityInputs.view.forms[0]);
|
|
275
|
+
const { positionals } = parseCommandArgs(args, activityInputs.view);
|
|
290
276
|
const id = positionals[0];
|
|
291
277
|
const { viewed, presented } = readWithActivityPresentation(activityIdSchema, id, () => {
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
278
|
+
const event = activity.getById(id);
|
|
279
|
+
return getOutputMode() === "json"
|
|
280
|
+
? { viewed: activity.attachTaskKeys([event])[0], presented: [] }
|
|
281
|
+
: { viewed: event, presented: presentActivities([event], { showsFullIds: true }) };
|
|
295
282
|
});
|
|
296
|
-
output(viewed, () => formatActivityList(presented, { showsDetails: true }));
|
|
283
|
+
output(viewed, () => formatActivityList(presented, { showsDetails: true, ...readTerminalProps() }));
|
|
297
284
|
},
|
|
298
285
|
help: `${generateCommandUsage("activity view", activityInputs.view)}
|
|
299
286
|
|
|
@@ -306,11 +293,8 @@ With --json, return one full activity record.
|
|
|
306
293
|
Example: zinn activity view 019abcdf-1234-7`,
|
|
307
294
|
},
|
|
308
295
|
};
|
|
309
|
-
/**
|
|
296
|
+
/** Validate input before opening the snapshot shared by activity reads and their lookups. */
|
|
310
297
|
function readWithActivityPresentation(schema, input, read) {
|
|
311
|
-
if (getOutputMode() === "json") {
|
|
312
|
-
return read();
|
|
313
|
-
}
|
|
314
298
|
const validation = schema.safeParse(input);
|
|
315
299
|
if (!validation.success) {
|
|
316
300
|
throw new InputValidationError(validation.error.issues);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { backup } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
5
|
-
import { output,
|
|
4
|
+
import { output, parseCommandArgs } from "../lib.js";
|
|
6
5
|
import packageJson from "../../package.json" with { type: "json" };
|
|
7
6
|
export const backupCommand = {
|
|
8
7
|
summary: "Save a verified copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.",
|
|
@@ -11,13 +10,7 @@ export const backupCommand = {
|
|
|
11
10
|
input: noInput,
|
|
12
11
|
results: [jsonResult("Backup")],
|
|
13
12
|
run: (args) => {
|
|
14
|
-
|
|
15
|
-
options: noInput.options,
|
|
16
|
-
args,
|
|
17
|
-
strict: true,
|
|
18
|
-
allowPositionals: true,
|
|
19
|
-
});
|
|
20
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
13
|
+
parseCommandArgs(args, noInput);
|
|
21
14
|
const created = backup.create({ client: "cli", version: packageJson.version });
|
|
22
15
|
output(created, (b) => `Saved a backup to ${b.path}`);
|
|
23
16
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
1
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
3
|
-
import { getOutputMode, output,
|
|
2
|
+
import { getOutputMode, output, parseCommandArgs } from "../lib.js";
|
|
4
3
|
import { formatCapabilities } from "../presentation/capabilities-presentation.js";
|
|
5
4
|
import { jsonResult } from "../results.js";
|
|
6
5
|
export const capabilitiesCommand = {
|
|
@@ -10,13 +9,7 @@ export const capabilitiesCommand = {
|
|
|
10
9
|
input: noInput,
|
|
11
10
|
results: [jsonResult("Capabilities")],
|
|
12
11
|
run: async (args) => {
|
|
13
|
-
|
|
14
|
-
options: noInput.options,
|
|
15
|
-
args,
|
|
16
|
-
strict: true,
|
|
17
|
-
allowPositionals: true,
|
|
18
|
-
});
|
|
19
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
12
|
+
parseCommandArgs(args, noInput);
|
|
20
13
|
const { generateCapabilities, getCapabilitySummary } = await import("../capabilities.js");
|
|
21
14
|
if (getOutputMode() === "json") {
|
|
22
15
|
output(generateCapabilities(), () => formatCapabilities(getCapabilitySummary()));
|
|
@@ -17,6 +17,7 @@ export declare const commentRouter: {
|
|
|
17
17
|
readonly kind: "text";
|
|
18
18
|
readonly name: "text";
|
|
19
19
|
};
|
|
20
|
+
readonly aliases: readonly ["body"];
|
|
20
21
|
};
|
|
21
22
|
readonly "text-file": {
|
|
22
23
|
readonly type: "string";
|
|
@@ -47,9 +48,6 @@ export declare const commentRouter: {
|
|
|
47
48
|
}];
|
|
48
49
|
};
|
|
49
50
|
results: import("../results.js").CommandResult[];
|
|
50
|
-
guessedFlags: {
|
|
51
|
-
"--body": (args: string[]) => string[];
|
|
52
|
-
};
|
|
53
51
|
run: (args: string[]) => Promise<void>;
|
|
54
52
|
help: string;
|
|
55
53
|
};
|
|
@@ -157,6 +155,7 @@ export declare const commentRouter: {
|
|
|
157
155
|
readonly kind: "text";
|
|
158
156
|
readonly name: "text";
|
|
159
157
|
};
|
|
158
|
+
readonly aliases: readonly ["body"];
|
|
160
159
|
};
|
|
161
160
|
readonly "text-file": {
|
|
162
161
|
readonly type: "string";
|
|
@@ -206,9 +205,6 @@ export declare const commentRouter: {
|
|
|
206
205
|
readonly notes: readonly [string, string];
|
|
207
206
|
};
|
|
208
207
|
results: import("../results.js").CommandResult[];
|
|
209
|
-
guessedFlags: {
|
|
210
|
-
"--body": (args: string[]) => string[];
|
|
211
|
-
};
|
|
212
208
|
run: (args: string[]) => Promise<void>;
|
|
213
209
|
help: string;
|
|
214
210
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { comment } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, getOptionInputs, taskKeyPositional, violatesConstraint, } from "../input.js";
|
|
5
|
-
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit,
|
|
4
|
+
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit, parseCommandArgs, } from "../lib.js";
|
|
6
5
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
7
6
|
import { expectedValueFlags } from "../expected-values.js";
|
|
8
7
|
import { checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
@@ -21,29 +20,13 @@ function requireCommentText(values) {
|
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
async function parseTextArgs(args) {
|
|
24
|
-
const { values, positionals
|
|
25
|
-
args,
|
|
26
|
-
options: commentInputs.create.options,
|
|
27
|
-
allowPositionals: true,
|
|
28
|
-
strict: true,
|
|
29
|
-
tokens: true,
|
|
30
|
-
});
|
|
31
|
-
validateUniqueOptions(tokens, commentInputs.create.options);
|
|
32
|
-
validatePositionals(positionals, commentInputs.create.forms[0]);
|
|
23
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.create);
|
|
33
24
|
requireCommentText(values);
|
|
34
25
|
const text = await resolveTextInput(values.text, values["text-file"], "--text");
|
|
35
26
|
return { key: positionals[0], text: text };
|
|
36
27
|
}
|
|
37
28
|
async function parseCommentEditArgs(args) {
|
|
38
|
-
const { values, positionals
|
|
39
|
-
args,
|
|
40
|
-
options: commentInputs.edit.options,
|
|
41
|
-
allowPositionals: true,
|
|
42
|
-
strict: true,
|
|
43
|
-
tokens: true,
|
|
44
|
-
});
|
|
45
|
-
validateUniqueOptions(tokens, commentInputs.edit.options);
|
|
46
|
-
validatePositionals(positionals, commentInputs.edit.forms[0]);
|
|
29
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.edit);
|
|
47
30
|
commentExpectations.parseValues(values);
|
|
48
31
|
checkSingleStdinReader(values, ["--text", ...commentExpectations.textFlags]);
|
|
49
32
|
const text = await resolveTextEdit(values, "--text");
|
|
@@ -52,10 +35,15 @@ async function parseCommentEditArgs(args) {
|
|
|
52
35
|
const expected = await commentExpectations.resolveText(values);
|
|
53
36
|
return { key: positionals[0], text: text, expected };
|
|
54
37
|
}
|
|
38
|
+
const commentTextOption = {
|
|
39
|
+
type: "string",
|
|
40
|
+
value: { kind: "text", name: "text" },
|
|
41
|
+
aliases: ["body"],
|
|
42
|
+
};
|
|
55
43
|
const commentInputs = {
|
|
56
44
|
create: {
|
|
57
45
|
options: {
|
|
58
|
-
text:
|
|
46
|
+
text: commentTextOption,
|
|
59
47
|
"text-file": textFileOption,
|
|
60
48
|
},
|
|
61
49
|
forms: [
|
|
@@ -88,7 +76,7 @@ const commentInputs = {
|
|
|
88
76
|
},
|
|
89
77
|
edit: {
|
|
90
78
|
options: {
|
|
91
|
-
text:
|
|
79
|
+
text: commentTextOption,
|
|
92
80
|
"text-file": textFileOption,
|
|
93
81
|
...textEditOptions,
|
|
94
82
|
...commentExpectations.options,
|
|
@@ -125,14 +113,6 @@ export const commentRouter = {
|
|
|
125
113
|
confirmation: { kind: "none" },
|
|
126
114
|
input: commentInputs.create,
|
|
127
115
|
results: [jsonResult("Comment")],
|
|
128
|
-
guessedFlags: {
|
|
129
|
-
"--body": (args) => [
|
|
130
|
-
"task",
|
|
131
|
-
"comment",
|
|
132
|
-
"create",
|
|
133
|
-
...renameFlag(args, commentInputs.create.options, "body", "text"),
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
116
|
run: async (args) => {
|
|
137
117
|
const props = await parseTextArgs(args);
|
|
138
118
|
const created = comment.create({ taskKey: props.key, text: props.text }, currentActor());
|
|
@@ -156,13 +136,7 @@ Example: zinn task comment create MDR-1 --text 'Ready for review'`,
|
|
|
156
136
|
input: commentInputs.list,
|
|
157
137
|
results: [jsonResult("CommentList")],
|
|
158
138
|
run: (args) => {
|
|
159
|
-
const { positionals } =
|
|
160
|
-
options: commentInputs.list.options,
|
|
161
|
-
args,
|
|
162
|
-
allowPositionals: true,
|
|
163
|
-
strict: true,
|
|
164
|
-
});
|
|
165
|
-
validatePositionals(positionals, commentInputs.list.forms[0]);
|
|
139
|
+
const { positionals } = parseCommandArgs(args, commentInputs.list);
|
|
166
140
|
output(presentComments(positionals[0]), formatCommentList);
|
|
167
141
|
},
|
|
168
142
|
help: `${generateCommandUsage("task comment list", commentInputs.list)}
|
|
@@ -178,13 +152,7 @@ Example: zinn task comment list MDR-1`,
|
|
|
178
152
|
input: commentInputs.view,
|
|
179
153
|
results: [jsonResult("Comment")],
|
|
180
154
|
run: (args) => {
|
|
181
|
-
const { positionals } =
|
|
182
|
-
options: commentInputs.view.options,
|
|
183
|
-
args,
|
|
184
|
-
allowPositionals: true,
|
|
185
|
-
strict: true,
|
|
186
|
-
});
|
|
187
|
-
validatePositionals(positionals, commentInputs.view.forms[0]);
|
|
155
|
+
const { positionals } = parseCommandArgs(args, commentInputs.view);
|
|
188
156
|
output(presentComment(comment.getByKey(positionals[0])), (entry) => formatCommentList([entry], { showsCreatedAt: false }));
|
|
189
157
|
},
|
|
190
158
|
help: `${generateCommandUsage("task comment view", commentInputs.view)}
|
|
@@ -201,14 +169,6 @@ Example: zinn task comment view 'MDR-1#1'`,
|
|
|
201
169
|
confirmation: { kind: "none" },
|
|
202
170
|
input: commentInputs.edit,
|
|
203
171
|
results: [jsonResult("CommentChange")],
|
|
204
|
-
guessedFlags: {
|
|
205
|
-
"--body": (args) => [
|
|
206
|
-
"task",
|
|
207
|
-
"comment",
|
|
208
|
-
"edit",
|
|
209
|
-
...renameFlag(args, commentInputs.edit.options, "body", "text"),
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
172
|
run: async (args) => {
|
|
213
173
|
const props = await parseCommentEditArgs(args);
|
|
214
174
|
const edited = comment.edit({ commentKey: props.key, text: props.text, expected: props.expected }, currentActor());
|
|
@@ -239,15 +199,7 @@ Examples:
|
|
|
239
199
|
input: commentInputs.delete,
|
|
240
200
|
results: [jsonResult("Comment")],
|
|
241
201
|
run: async (args) => {
|
|
242
|
-
const { values, positionals
|
|
243
|
-
args,
|
|
244
|
-
options: commentInputs.delete.options,
|
|
245
|
-
allowPositionals: true,
|
|
246
|
-
strict: true,
|
|
247
|
-
tokens: true,
|
|
248
|
-
});
|
|
249
|
-
validateUniqueOptions(tokens, commentInputs.delete.options);
|
|
250
|
-
validatePositionals(positionals, commentInputs.delete.forms[0]);
|
|
202
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.delete);
|
|
251
203
|
const commentMatch = comment.getByKey(positionals[0]);
|
|
252
204
|
const canDelete = await confirmAction(`Are you sure you want to delete ${commentMatch.key}?`, values.yes === true);
|
|
253
205
|
const presented = presentComment(commentMatch);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { doctor } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
5
|
-
import { output,
|
|
4
|
+
import { output, parseCommandArgs } from "../lib.js";
|
|
6
5
|
import { jsonResult } from "../results.js";
|
|
7
6
|
import { formatDoctor, presentDoctor } from "../presentation/doctor-presentation.js";
|
|
8
7
|
import { describeSkillCopy } from "../presentation/skill-status-presentation.js";
|
|
@@ -61,13 +60,7 @@ export const doctorCommand = {
|
|
|
61
60
|
input: noInput,
|
|
62
61
|
results: [{ ...jsonResult("Doctor"), findingsExitCode: 1 }],
|
|
63
62
|
run: (args) => {
|
|
64
|
-
|
|
65
|
-
options: noInput.options,
|
|
66
|
-
args,
|
|
67
|
-
strict: true,
|
|
68
|
-
allowPositionals: true,
|
|
69
|
-
});
|
|
70
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
63
|
+
parseCommandArgs(args, noInput);
|
|
71
64
|
const report = presentDoctor(doctor.check(), checkAgentSkill());
|
|
72
65
|
output(report, formatDoctor);
|
|
73
66
|
if (!report.ok) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { info } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
5
|
-
import { output,
|
|
4
|
+
import { output, parseCommandArgs } from "../lib.js";
|
|
6
5
|
import { formatInfo, presentInfo } from "../presentation/info-presentation.js";
|
|
7
6
|
export const infoCommand = {
|
|
8
7
|
summary: "Show the selected store, settings sources, telemetry state, database schema state and CLI, core and runtime versions.",
|
|
@@ -11,13 +10,7 @@ export const infoCommand = {
|
|
|
11
10
|
input: noInput,
|
|
12
11
|
results: [jsonResult("Info")],
|
|
13
12
|
run: (args) => {
|
|
14
|
-
|
|
15
|
-
options: noInput.options,
|
|
16
|
-
args,
|
|
17
|
-
strict: true,
|
|
18
|
-
allowPositionals: true,
|
|
19
|
-
});
|
|
20
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
13
|
+
parseCommandArgs(args, noInput);
|
|
21
14
|
output(presentInfo(info.get()), formatInfo);
|
|
22
15
|
},
|
|
23
16
|
help: `${generateCommandUsage("info", noInput)}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { label, labelColorSchema, labelCreateSchema, labelDeleteSchema, labelEditSchema, } from "@zinn-dev/core";
|
|
4
3
|
import { CliError } from "../errors.js";
|
|
5
4
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
6
|
-
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges,
|
|
5
|
+
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, parseCommandArgs, } from "../lib.js";
|
|
7
6
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
8
7
|
import { expectedValueFlags } from "../expected-values.js";
|
|
9
8
|
import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
@@ -89,15 +88,7 @@ export const labelRouter = {
|
|
|
89
88
|
input: labelInputs.create,
|
|
90
89
|
results: [jsonResult("Label")],
|
|
91
90
|
run: async (args) => {
|
|
92
|
-
const { values, positionals
|
|
93
|
-
args,
|
|
94
|
-
options: labelInputs.create.options,
|
|
95
|
-
allowPositionals: true,
|
|
96
|
-
strict: true,
|
|
97
|
-
tokens: true,
|
|
98
|
-
});
|
|
99
|
-
validateUniqueOptions(tokens, labelInputs.create.options);
|
|
100
|
-
validatePositionals(positionals, labelInputs.create.forms[0]);
|
|
91
|
+
const { values, positionals } = parseCommandArgs(args, labelInputs.create);
|
|
101
92
|
checkFieldsBeforeText(labelCreateSchema, { name: positionals[0], color: values.color });
|
|
102
93
|
const description = await resolveTextInput(values.description, values["description-file"], "--description");
|
|
103
94
|
const input = labelCreateSchema.parse({
|
|
@@ -130,13 +121,7 @@ Example: zinn label create bug --description 'Unexpected behavior' --color red`,
|
|
|
130
121
|
input: labelInputs.list,
|
|
131
122
|
results: [jsonResult("LabelList")],
|
|
132
123
|
run: (args) => {
|
|
133
|
-
|
|
134
|
-
options: labelInputs.list.options,
|
|
135
|
-
args,
|
|
136
|
-
strict: true,
|
|
137
|
-
allowPositionals: true,
|
|
138
|
-
});
|
|
139
|
-
validatePositionals(positionals, labelInputs.list.forms[0]);
|
|
124
|
+
parseCommandArgs(args, labelInputs.list);
|
|
140
125
|
output(label.getAll().map(presentLabel), (entries) => formatLabelList(entries, { showsDescriptionPreview: true }));
|
|
141
126
|
},
|
|
142
127
|
help: `${generateCommandUsage("label list", labelInputs.list)}
|
|
@@ -152,13 +137,7 @@ Use label view <name> for the full description. --json keeps the full text.`,
|
|
|
152
137
|
input: labelInputs.view,
|
|
153
138
|
results: [jsonResult("Label")],
|
|
154
139
|
run: (args) => {
|
|
155
|
-
const { positionals } =
|
|
156
|
-
args,
|
|
157
|
-
options: labelInputs.view.options,
|
|
158
|
-
strict: true,
|
|
159
|
-
allowPositionals: true,
|
|
160
|
-
});
|
|
161
|
-
validatePositionals(positionals, labelInputs.view.forms[0]);
|
|
140
|
+
const { positionals } = parseCommandArgs(args, labelInputs.view);
|
|
162
141
|
const props = labelDeleteSchema.parse({ name: positionals[0] });
|
|
163
142
|
const labelMatch = label.getByName(props.name);
|
|
164
143
|
if (labelMatch == null) {
|
|
@@ -184,15 +163,7 @@ Example: zinn label view bug`,
|
|
|
184
163
|
input: labelInputs.edit,
|
|
185
164
|
results: [jsonResult("LabelChange")],
|
|
186
165
|
run: async (args) => {
|
|
187
|
-
const { values, positionals
|
|
188
|
-
args,
|
|
189
|
-
options: labelInputs.edit.options,
|
|
190
|
-
allowPositionals: true,
|
|
191
|
-
strict: true,
|
|
192
|
-
tokens: true,
|
|
193
|
-
});
|
|
194
|
-
validateUniqueOptions(tokens, labelInputs.edit.options);
|
|
195
|
-
validatePositionals(positionals, labelInputs.edit.forms[0]);
|
|
166
|
+
const { values, positionals } = parseCommandArgs(args, labelInputs.edit);
|
|
196
167
|
const expected = labelExpectations.parseValues(values);
|
|
197
168
|
checkFieldsBeforeText(labelEditSchema, {
|
|
198
169
|
labelName: positionals[0],
|
|
@@ -243,15 +214,7 @@ Examples:
|
|
|
243
214
|
input: labelInputs.delete,
|
|
244
215
|
results: [jsonResult("Label")],
|
|
245
216
|
run: async (args) => {
|
|
246
|
-
const { values, positionals
|
|
247
|
-
args,
|
|
248
|
-
options: labelInputs.delete.options,
|
|
249
|
-
strict: true,
|
|
250
|
-
allowPositionals: true,
|
|
251
|
-
tokens: true,
|
|
252
|
-
});
|
|
253
|
-
validateUniqueOptions(tokens, labelInputs.delete.options);
|
|
254
|
-
validatePositionals(positionals, labelInputs.delete.forms[0]);
|
|
217
|
+
const { values, positionals } = parseCommandArgs(args, labelInputs.delete);
|
|
255
218
|
const props = labelDeleteSchema.parse({ name: positionals[0] });
|
|
256
219
|
const labelMatch = label.getByName(props.name);
|
|
257
220
|
if (labelMatch == null) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { migrate, DatabaseChangeAppliedError, MigrationRefusedError } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
5
4
|
import { reportLockWait } from "../database.js";
|
|
6
|
-
import { diagnostic, output,
|
|
5
|
+
import { diagnostic, output, parseCommandArgs } from "../lib.js";
|
|
7
6
|
import packageJson from "../../package.json" with { type: "json" };
|
|
8
7
|
export const migrateCommand = {
|
|
9
8
|
summary: "Upgrade an existing database to the latest schema version.",
|
|
@@ -12,13 +11,7 @@ export const migrateCommand = {
|
|
|
12
11
|
input: noInput,
|
|
13
12
|
results: [jsonResult("Migrate")],
|
|
14
13
|
run: (args) => {
|
|
15
|
-
|
|
16
|
-
options: noInput.options,
|
|
17
|
-
args,
|
|
18
|
-
strict: true,
|
|
19
|
-
allowPositionals: true,
|
|
20
|
-
});
|
|
21
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
14
|
+
parseCommandArgs(args, noInput);
|
|
22
15
|
try {
|
|
23
16
|
const result = migrate.run({
|
|
24
17
|
client: "cli",
|