@zinn-dev/cli 0.40.0 → 0.41.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.
Files changed (60) hide show
  1. package/README.md +166 -38
  2. package/index.js +24 -13
  3. package/package.json +7 -2
  4. package/skills/zinn/SKILL.md +63 -0
  5. package/src/actor.d.ts +2 -1
  6. package/src/actor.js +78 -11
  7. package/src/capabilities-schema.d.ts +163 -0
  8. package/src/capabilities-schema.js +124 -0
  9. package/src/capabilities.d.ts +21 -0
  10. package/src/capabilities.js +22 -0
  11. package/src/database.d.ts +1 -1
  12. package/src/database.js +4 -4
  13. package/src/errors.d.ts +158 -0
  14. package/src/errors.js +224 -0
  15. package/src/input.d.ts +116 -0
  16. package/src/input.js +119 -0
  17. package/src/lib.d.ts +42 -7
  18. package/src/lib.js +213 -17
  19. package/src/presentation/activity-presentation.js +16 -2
  20. package/src/presentation/column-presentation.d.ts +3 -5
  21. package/src/presentation/info-presentation.d.ts +4 -0
  22. package/src/presentation/info-presentation.js +96 -0
  23. package/src/presentation/task-presentation.d.ts +2 -10
  24. package/src/project.d.ts +6 -0
  25. package/src/project.js +23 -10
  26. package/src/result-schemas.d.ts +987 -0
  27. package/src/result-schemas.js +220 -0
  28. package/src/results.d.ts +23 -0
  29. package/src/results.js +17 -0
  30. package/src/routes/activity-router.d.ts +71 -0
  31. package/src/routes/activity-router.js +59 -11
  32. package/src/routes/backup-router.d.ts +17 -0
  33. package/src/routes/backup-router.js +15 -3
  34. package/src/routes/capabilities-router.d.ts +21 -0
  35. package/src/routes/capabilities-router.js +28 -0
  36. package/src/routes/comment-router.d.ts +183 -4
  37. package/src/routes/comment-router.js +136 -29
  38. package/src/routes/info-router.d.ts +21 -0
  39. package/src/routes/info-router.js +29 -0
  40. package/src/routes/label-router.d.ts +165 -0
  41. package/src/routes/label-router.js +111 -29
  42. package/src/routes/migrate-router.d.ts +17 -0
  43. package/src/routes/migrate-router.js +17 -5
  44. package/src/routes/project-router.d.ts +349 -0
  45. package/src/routes/project-router.js +278 -92
  46. package/src/routes/reindex-router.d.ts +17 -0
  47. package/src/routes/reindex-router.js +15 -3
  48. package/src/routes/relation-router.d.ts +108 -12
  49. package/src/routes/relation-router.js +74 -14
  50. package/src/routes/restore-router.d.ts +29 -0
  51. package/src/routes/restore-router.js +30 -13
  52. package/src/routes/router.d.ts +1 -1
  53. package/src/routes/router.js +44 -25
  54. package/src/routes/routes.d.ts +1565 -0
  55. package/src/routes/routes.js +5 -1
  56. package/src/routes/task-router.d.ts +861 -0
  57. package/src/routes/task-router.js +419 -163
  58. package/src/text-edit.d.ts +20 -2
  59. package/src/text-edit.js +22 -10
  60. package/src/types.d.ts +14 -0
@@ -1,13 +1,16 @@
1
+ import { jsonResult } from "../results.js";
1
2
  import { parseArgs } from "node:util";
2
- import { column, project } from "@zinn-dev/core";
3
- import { canPrompt, confirmAction, failureMessage, output, quit, UsageError, validatePositionals, validateUniqueOptions, } from "../lib.js";
4
- import { resolveTextEdit, textEditHelp, textEditOptions, textEditUsage } from "../text-edit.js";
3
+ import { column, project, columnOrderSchema } from "@zinn-dev/core";
4
+ import { CliError } from "../errors.js";
5
+ import { generateCommandUsage, getOptionInputs, noInput, violatesConstraint } from "../input.js";
6
+ import { confirmationDescription, canPrompt, confirmAction, dashValueHelp, diagnostic, output, quit, validatePositionals, validateOrderForms, requireStringOption, validateUniqueOptions, } from "../lib.js";
7
+ import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
5
8
  import { formatColumnList } from "../presentation/column-presentation.js";
6
9
  import { formatDescriptionPreview } from "../presentation/description-presentation.js";
7
10
  import { formatCellSeparator, formatRows } from "../presentation/row-layout.js";
8
11
  import { formatSection } from "../presentation/section.js";
9
12
  import { currentActor } from "../actor.js";
10
- import { resolveProjectKey } from "../project.js";
13
+ import { resolveProjectKey, requiredProjectDescription } from "../project.js";
11
14
  function presentProject(projectMatch) {
12
15
  return { key: projectMatch.key, name: projectMatch.name, description: projectMatch.description };
13
16
  }
@@ -30,28 +33,160 @@ function presentColumn(columnMatch) {
30
33
  function formatColumn(presented) {
31
34
  return formatColumnList([presented], { showsProject: true });
32
35
  }
36
+ const projectEditConstraint = {
37
+ kind: "atLeastOne",
38
+ members: ["option:name", "option:description"],
39
+ };
40
+ const projectInputs = {
41
+ create: {
42
+ options: {
43
+ name: { type: "string", value: { kind: "text", name: "text" } },
44
+ description: { type: "string", value: { kind: "text", name: "text" } },
45
+ },
46
+ forms: [
47
+ {
48
+ id: "default",
49
+ positionals: [{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } }],
50
+ },
51
+ ],
52
+ constraints: [],
53
+ },
54
+ list: noInput,
55
+ view: {
56
+ options: {},
57
+ forms: [
58
+ {
59
+ id: "default",
60
+ positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
61
+ },
62
+ ],
63
+ constraints: [],
64
+ notes: [requiredProjectDescription],
65
+ },
66
+ edit: {
67
+ options: {
68
+ name: { type: "string", value: { kind: "text", name: "text" } },
69
+ description: { type: "string", value: { kind: "text", name: "text" } },
70
+ ...textEditOptions,
71
+ },
72
+ forms: [
73
+ {
74
+ id: "default",
75
+ positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
76
+ },
77
+ ],
78
+ constraints: [...textEditConstraints("--description"), projectEditConstraint],
79
+ notes: [requiredProjectDescription, textEditHelp("--description")],
80
+ },
81
+ delete: {
82
+ options: { yes: { type: "boolean" } },
83
+ forms: [
84
+ {
85
+ id: "default",
86
+ positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
87
+ },
88
+ ],
89
+ constraints: [],
90
+ notes: [requiredProjectDescription],
91
+ },
92
+ column_create: {
93
+ options: {},
94
+ forms: [
95
+ {
96
+ id: "default",
97
+ positionals: [
98
+ { name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
99
+ { name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
100
+ ],
101
+ },
102
+ ],
103
+ constraints: [],
104
+ },
105
+ column_list: {
106
+ options: {},
107
+ forms: [
108
+ {
109
+ id: "default",
110
+ positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
111
+ },
112
+ ],
113
+ constraints: [],
114
+ notes: [requiredProjectDescription],
115
+ },
116
+ column_edit: {
117
+ options: { name: { type: "string", required: true, value: { kind: "text", name: "text" } } },
118
+ forms: [
119
+ {
120
+ id: "default",
121
+ positionals: [
122
+ { name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
123
+ { name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
124
+ ],
125
+ },
126
+ ],
127
+ constraints: [],
128
+ },
129
+ column_order: {
130
+ options: {},
131
+ forms: [
132
+ {
133
+ id: "absolute",
134
+ positionals: [
135
+ { name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
136
+ { name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
137
+ {
138
+ name: "direction",
139
+ min: 1,
140
+ max: 1,
141
+ value: { kind: "enum", choices: columnOrderSchema.options[0].shape.direction.options },
142
+ },
143
+ ],
144
+ },
145
+ {
146
+ id: "relative",
147
+ positionals: [
148
+ { name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
149
+ { name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
150
+ {
151
+ name: "direction",
152
+ min: 1,
153
+ max: 1,
154
+ value: { kind: "enum", choices: columnOrderSchema.options[1].shape.direction.options },
155
+ },
156
+ { name: "target-column-name", min: 1, max: 1, value: { kind: "column-name" } },
157
+ ],
158
+ },
159
+ ],
160
+ constraints: [],
161
+ },
162
+ };
33
163
  export const projectRouter = {
34
164
  create: {
165
+ summary: "Create a project with the default columns.",
166
+ effects: { domain: "create", storage: "normal-open" },
167
+ confirmation: { kind: "none" },
168
+ input: projectInputs.create,
169
+ results: [jsonResult("Project")],
35
170
  run: (args) => {
36
171
  const { values, positionals, tokens } = parseArgs({
37
172
  args,
38
- options: { name: { type: "string" }, description: { type: "string" } },
173
+ options: projectInputs.create.options,
39
174
  allowPositionals: true,
40
175
  strict: true,
41
176
  tokens: true,
42
177
  });
43
- validateUniqueOptions(tokens);
44
- validatePositionals(positionals, ["<project-key>"]);
178
+ validateUniqueOptions(tokens, projectInputs.create.options);
179
+ validatePositionals(positionals, projectInputs.create.forms[0]);
45
180
  const projectKey = positionals[0];
46
181
  try {
47
182
  const createdProject = project.create({ key: projectKey, name: values.name, description: values.description }, currentActor());
48
183
  output(presentProject(createdProject), formatProject);
49
184
  }
50
185
  catch (err) {
51
- quit(failureMessage(err, "Something went wrong"));
186
+ throw err;
52
187
  }
53
188
  },
54
- help: `Usage: zinn project create <project-key> [--name <text>] [--description <text>]
189
+ help: `${generateCommandUsage("project create", projectInputs.create)}
55
190
 
56
191
  Create a project with the default columns.
57
192
  Project keys are stored in uppercase.
@@ -60,29 +195,51 @@ An omitted name defaults to the uppercase project key.
60
195
  Names are trimmed and cannot be blank or contain line breaks or control characters.
61
196
  Descriptions may contain multiple lines. If omitted, they are saved as null.
62
197
 
63
- Example: zinn project create MDR --name "Macrodata Refinement"`,
198
+ ${dashValueHelp("--description")}
199
+
200
+ Example: zinn project create MDR --name 'Macrodata Refinement'`,
64
201
  },
65
202
  list: {
203
+ summary: "List projects, their keys, and truncated description previews.",
204
+ effects: { domain: "read", storage: "normal-open" },
205
+ confirmation: { kind: "none" },
206
+ input: projectInputs.list,
207
+ results: [jsonResult("ProjectList")],
66
208
  run: (args) => {
67
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
68
- validatePositionals(positionals, []);
209
+ const { positionals } = parseArgs({
210
+ options: projectInputs.list.options,
211
+ args,
212
+ allowPositionals: true,
213
+ strict: true,
214
+ });
215
+ validatePositionals(positionals, projectInputs.list.forms[0]);
69
216
  const projects = project.getAll();
70
217
  output(projects.map(presentProject), formatProjectList);
71
218
  },
72
- help: `Usage: zinn project list
219
+ help: `${generateCommandUsage("project list", projectInputs.list)}
73
220
 
74
221
  List projects, their keys, and truncated description previews.
75
222
 
76
223
  Example: zinn project list`,
77
224
  },
78
225
  view: {
226
+ summary: "Show a project with its description and the number of tasks in each column.",
227
+ effects: { domain: "read", storage: "normal-open" },
228
+ confirmation: { kind: "none" },
229
+ input: projectInputs.view,
230
+ results: [jsonResult("ProjectView")],
79
231
  run: (args) => {
80
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
81
- validatePositionals(positionals, ["[<project-key>]"]);
232
+ const { positionals } = parseArgs({
233
+ options: projectInputs.view.options,
234
+ args,
235
+ allowPositionals: true,
236
+ strict: true,
237
+ });
238
+ validatePositionals(positionals, projectInputs.view.forms[0]);
82
239
  const projectKey = resolveProjectKey(positionals[0], { required: true });
83
240
  const projectMatch = project.getByKey(projectKey);
84
241
  if (projectMatch == null) {
85
- quit(`Project with key "${project.standardizeKey(projectKey)}" does not exist!`);
242
+ throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist!`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
86
243
  }
87
244
  const taskCounts = column.getTaskCountsByProjectKey(projectMatch.key);
88
245
  const presentedProject = {
@@ -107,72 +264,89 @@ Example: zinn project list`,
107
264
  return sections.join("\n\n");
108
265
  });
109
266
  },
110
- help: `Usage: zinn project view [<project-key>]
267
+ help: `${generateCommandUsage("project view", projectInputs.view)}
111
268
 
112
269
  Show a project with its description and the number of tasks in each column.
113
- An omitted project key uses defaultProject from settings, if present.
114
- If no default project is set, the key is required.
270
+ ${requiredProjectDescription}
115
271
  The description prints in full, keeping its line breaks. Archived tasks are counted as one total.
116
272
 
117
273
  Example: zinn project view MDR`,
118
274
  },
119
275
  edit: {
276
+ summary: "Change the supplied project fields. At least one edit flag is required.",
277
+ effects: { domain: "update", storage: "normal-open" },
278
+ confirmation: { kind: "none" },
279
+ input: projectInputs.edit,
280
+ results: [jsonResult("Project")],
120
281
  run: (args) => {
121
282
  const { values, positionals, tokens } = parseArgs({
122
283
  args,
123
- options: { name: { type: "string" }, description: { type: "string" }, ...textEditOptions },
284
+ options: projectInputs.edit.options,
124
285
  allowPositionals: true,
125
286
  strict: true,
126
287
  tokens: true,
127
288
  });
128
- validateUniqueOptions(tokens);
129
- validatePositionals(positionals, ["[<project-key>]"]);
289
+ validateUniqueOptions(tokens, projectInputs.edit.options);
290
+ validatePositionals(positionals, projectInputs.edit.forms[0]);
130
291
  const projectKey = resolveProjectKey(positionals[0], { required: true });
131
292
  const description = resolveTextEdit(values.description, values, "--description");
132
- if (values.name === undefined && description === undefined) {
133
- quit("Provide an edit flag: --name or --description");
293
+ if (violatesConstraint(projectEditConstraint, getOptionInputs({ ...values, description }))) {
294
+ quit("Provide an edit flag: --name or --description", undefined, { field: [] });
134
295
  }
135
296
  const editedProject = project.edit({ projectKey, name: values.name, description }, currentActor());
136
297
  output(presentProject(editedProject), formatProject);
137
298
  },
138
- help: `Usage: zinn project edit [<project-key>] [--name <text>] [--description <text> ${textEditUsage}]
299
+ help: `${generateCommandUsage("project edit", projectInputs.edit)}
139
300
 
140
301
  Change the supplied project fields. At least one edit flag is required.
141
- An omitted project key uses defaultProject from settings, if present.
142
- If no default project is set, the key is required.
143
- Use --description "" to clear the description.
302
+ ${requiredProjectDescription}
303
+ Use --description '' to clear the description.
144
304
 
145
305
  ${textEditHelp("--description")}
146
306
 
307
+ ${dashValueHelp("--description")}
308
+
147
309
  Examples:
148
- zinn project edit MDR --name "Macrodata Refinement"
149
- zinn project edit MDR --description "database" --replacing "board" --all`,
310
+ zinn project edit MDR --name 'Macrodata Refinement'
311
+ zinn project edit MDR --description database --replacing board --all`,
150
312
  },
151
313
  delete: {
314
+ summary: "Permanently delete a project and all of its columns and tasks after confirmation.",
315
+ effects: { domain: "delete", storage: "normal-open" },
316
+ confirmation: {
317
+ kind: "project-delete",
318
+ description: `${confirmationDescription} When the project key is omitted, deleting the configured default project always requires a terminal prompt; --yes is ignored.`,
319
+ },
320
+ input: projectInputs.delete,
321
+ results: [jsonResult("Project")],
152
322
  run: async (args) => {
153
323
  const { values, positionals, tokens } = parseArgs({
154
324
  args,
155
- options: { yes: { type: "boolean" } },
325
+ options: projectInputs.delete.options,
156
326
  allowPositionals: true,
157
327
  strict: true,
158
328
  tokens: true,
159
329
  });
160
- validateUniqueOptions(tokens);
161
- validatePositionals(positionals, ["[<project-key>]"]);
330
+ validateUniqueOptions(tokens, projectInputs.delete.options);
331
+ validatePositionals(positionals, projectInputs.delete.forms[0]);
162
332
  const typedProjectKey = positionals[0];
163
333
  const projectKey = resolveProjectKey(typedProjectKey, { required: true });
164
334
  try {
165
335
  const projectMatch = project.getByKey(projectKey);
166
336
  if (projectMatch == null) {
167
- throw new Error(`Project with key "${projectKey}" does not exist!`);
337
+ throw new CliError(`Project with key "${projectKey}" does not exist!`, "not_found", {
338
+ entity: "project",
339
+ key: projectKey,
340
+ source: "explicit",
341
+ });
168
342
  }
169
343
  // Like `gh repo delete`: --yes never skips the prompt for a project the command did not name
170
344
  const isYesIgnored = values.yes === true && typedProjectKey === undefined;
171
345
  if (isYesIgnored && !canPrompt()) {
172
- quit(`Cannot delete the default project ${projectMatch.key} without a terminal. Type its key to use --yes: zinn project delete ${projectMatch.key} --yes`);
346
+ quit(`Cannot delete the default project ${projectMatch.key} without a terminal. Type its key to use --yes: zinn project delete ${projectMatch.key} --yes`, undefined, { argument: "project-key", reason: "confirmation_required" });
173
347
  }
174
348
  if (isYesIgnored) {
175
- console.error("Warning: --yes is ignored because no project key was typed");
349
+ diagnostic("Warning: --yes is ignored because no project key was typed");
176
350
  }
177
351
  const canDelete = await confirmAction(`Are you sure you want to delete ${projectMatch.key} and all of its columns and tasks?`, values.yes === true && typedProjectKey !== undefined, typedProjectKey === undefined
178
352
  ? "Project deletion with --json needs a typed <project-key> and --yes"
@@ -186,24 +360,33 @@ Examples:
186
360
  }
187
361
  }
188
362
  catch (err) {
189
- quit(failureMessage(err, "Something went wrong"));
363
+ throw err;
190
364
  }
191
365
  },
192
- help: `Usage: zinn project delete [<project-key>] [--yes]
366
+ help: `${generateCommandUsage("project delete", projectInputs.delete)}
193
367
 
194
368
  Permanently delete a project and all of its columns and tasks after confirmation.
195
- An omitted project key uses defaultProject from settings, if present.
196
- If no default project is set, the key is required.
197
- With the default, confirmation is always required: --yes is ignored, and without a terminal the command refuses.
369
+ ${requiredProjectDescription}
370
+ When the project key is omitted, confirmation is always required: --yes is ignored, and without a terminal the command refuses.
198
371
  Use a typed project key and --yes to skip the prompt, including with --json.
199
372
 
200
373
  Example: zinn project delete MDR`,
201
374
  },
202
375
  column: {
203
376
  create: {
377
+ summary: "Add a column at the end of a project's board.",
378
+ effects: { domain: "create", storage: "normal-open" },
379
+ confirmation: { kind: "none" },
380
+ input: projectInputs.column_create,
381
+ results: [jsonResult("Column")],
204
382
  run: (args) => {
205
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
206
- validatePositionals(positionals, ["<project-key>", "<column-name>"]);
383
+ const { positionals } = parseArgs({
384
+ options: projectInputs.column_create.options,
385
+ args,
386
+ allowPositionals: true,
387
+ strict: true,
388
+ });
389
+ validatePositionals(positionals, projectInputs.column_create.forms[0]);
207
390
  const projectKey = positionals[0];
208
391
  const columnName = positionals[1];
209
392
  try {
@@ -211,20 +394,30 @@ Example: zinn project delete MDR`,
211
394
  output(presentColumn(createdColumn), formatColumn);
212
395
  }
213
396
  catch (err) {
214
- quit(failureMessage(err, "Something went wrong"));
397
+ throw err;
215
398
  }
216
399
  },
217
- help: `Usage: zinn project column create <project-key> <column-name>
400
+ help: `${generateCommandUsage("project column create", projectInputs.column_create)}
218
401
 
219
402
  Add a column at the end of a project's board.
220
403
  Names are trimmed, cannot be blank or contain line breaks or control characters, and must be unique within the project regardless of casing.
221
404
 
222
- Example: zinn project column create MDR "Boardlog"`,
405
+ Example: zinn project column create MDR Boardlog`,
223
406
  },
224
407
  list: {
408
+ summary: "List a project's columns in board order with their unarchived task counts.",
409
+ effects: { domain: "read", storage: "normal-open" },
410
+ confirmation: { kind: "none" },
411
+ input: projectInputs.column_list,
412
+ results: [jsonResult("ColumnList")],
225
413
  run: (args) => {
226
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
227
- validatePositionals(positionals, ["[<project-key>]"]);
414
+ const { positionals } = parseArgs({
415
+ options: projectInputs.column_list.options,
416
+ args,
417
+ allowPositionals: true,
418
+ strict: true,
419
+ });
420
+ validatePositionals(positionals, projectInputs.column_list.forms[0]);
228
421
  const projectKey = resolveProjectKey(positionals[0], { required: true });
229
422
  const taskCounts = column.getTaskCountsByProjectKey(projectKey);
230
423
  const columns = taskCounts.columns.map((columnCount) => ({
@@ -235,36 +428,38 @@ Example: zinn project column create MDR "Boardlog"`,
235
428
  showsTaskCounts: true,
236
429
  }));
237
430
  },
238
- help: `Usage: zinn project column list [<project-key>]
431
+ help: `${generateCommandUsage("project column list", projectInputs.column_list)}
239
432
 
240
433
  List a project's columns in board order with their unarchived task counts.
241
- An omitted project key uses defaultProject from settings, if present.
242
- If no default project is set, the key is required.
434
+ ${requiredProjectDescription}
243
435
 
244
436
  Example: zinn project column list MDR`,
245
437
  },
246
438
  edit: {
439
+ summary: "Rename a column.",
440
+ effects: { domain: "update", storage: "normal-open" },
441
+ confirmation: { kind: "none" },
442
+ input: projectInputs.column_edit,
443
+ results: [jsonResult("Column")],
247
444
  run: (args) => {
248
445
  const { values, positionals, tokens } = parseArgs({
249
446
  args,
250
- options: { name: { type: "string" } },
447
+ options: projectInputs.column_edit.options,
251
448
  allowPositionals: true,
252
449
  strict: true,
253
450
  tokens: true,
254
451
  });
255
- validateUniqueOptions(tokens);
256
- validatePositionals(positionals, ["<project-key>", "<column-name>"]);
257
- if (values.name === undefined) {
258
- quit("Provide an edit flag: --name");
259
- }
452
+ validateUniqueOptions(tokens, projectInputs.column_edit.options);
453
+ validatePositionals(positionals, projectInputs.column_edit.forms[0]);
454
+ const name = requireStringOption(projectInputs.column_edit.options.name, values.name, "name", "Provide an edit flag: --name");
260
455
  const editedColumn = column.edit({
261
456
  projectKey: positionals[0],
262
457
  columnName: positionals[1],
263
- name: values.name,
458
+ name,
264
459
  }, currentActor());
265
460
  output(presentColumn(editedColumn), formatColumn);
266
461
  },
267
- help: `Usage: zinn project column edit <project-key> <column-name> --name <text>
462
+ help: `${generateCommandUsage("project column edit", projectInputs.column_edit)}
268
463
 
269
464
  Rename a column.
270
465
  The --name flag is required.
@@ -273,48 +468,39 @@ Columns are matched by name, and matching is case-insensitive.
273
468
  Names are trimmed, and must remain unique within the same project.
274
469
  Changing only the casing of a column's own name is allowed.
275
470
 
276
- Example: zinn project column edit MDR "In Progress" --name "Refining"`,
471
+ ${dashValueHelp("--name")}
472
+
473
+ Example: zinn project column edit MDR 'In Progress' --name Refining`,
277
474
  },
278
475
  order: {
476
+ summary: "Change a column's position on the project's board.",
477
+ effects: { domain: "update", storage: "normal-open" },
478
+ confirmation: { kind: "none" },
479
+ input: projectInputs.column_order,
480
+ results: [jsonResult("Column")],
279
481
  run: (args) => {
280
- const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
281
- /**
282
- * The words every direction needs. Only whether they are there is checked here,
283
- * since the direction decides whether a target column follows.
284
- */
285
- const leadingWords = [
286
- "<project-key>",
287
- "<column-name>",
288
- "{first|previous|next|last|before|after}",
289
- ];
290
- validatePositionals(positionals.slice(0, leadingWords.length), leadingWords);
482
+ const { positionals } = parseArgs({
483
+ options: projectInputs.column_order.options,
484
+ args,
485
+ allowPositionals: true,
486
+ strict: true,
487
+ });
488
+ const form = validateOrderForms(positionals, projectInputs.column_order.forms);
291
489
  const projectKey = positionals[0];
292
490
  const columnName = positionals[1];
293
- const direction = positionals[2];
294
491
  let orderedColumn;
295
- switch (direction) {
296
- case "before":
297
- case "after": {
298
- validatePositionals(positionals, [...leadingWords, "<target-column-name>"]);
299
- orderedColumn = column.order({ projectKey, columnName, direction, targetColumnName: positionals[3] }, currentActor());
300
- break;
301
- }
302
- case "first":
303
- case "previous":
304
- case "next":
305
- case "last": {
306
- validatePositionals(positionals, leadingWords);
307
- orderedColumn = column.order({ projectKey, columnName, direction }, currentActor());
308
- break;
309
- }
310
- default:
311
- throw new UsageError(`Unknown order direction "${direction}"`);
492
+ if (form.id === "relative") {
493
+ const direction = positionals[2];
494
+ orderedColumn = column.order({ projectKey, columnName, direction, targetColumnName: positionals[3] }, currentActor());
495
+ }
496
+ else {
497
+ const direction = positionals[2];
498
+ orderedColumn = column.order({ projectKey, columnName, direction }, currentActor());
312
499
  }
313
500
  // TODO: maybe also print the new full column state?
314
501
  output(presentColumn(orderedColumn), formatColumn);
315
502
  },
316
- help: `Usage: zinn project column order <project-key> <column-name> {first|previous|next|last}
317
- zinn project column order <project-key> <column-name> {before|after} <target-column-name>
503
+ help: `${generateCommandUsage("project column order", projectInputs.column_order)}
318
504
 
319
505
  Change a column's position on the project's board.
320
506
  Use first or last for either end, previous or next for one position,
@@ -322,7 +508,7 @@ Use first or last for either end, previous or next for one position,
322
508
 
323
509
  Columns are matched by name, and matching is case-insensitive.
324
510
 
325
- Example: zinn project column order MDR Review before "In Progress"`,
511
+ Example: zinn project column order MDR Review before 'In Progress'`,
326
512
  },
327
513
  },
328
514
  };
@@ -1,4 +1,21 @@
1
1
  export declare const reindexCommand: {
2
+ summary: string;
3
+ effects: {
4
+ domain: "none";
5
+ storage: "reindex";
6
+ };
7
+ confirmation: {
8
+ kind: "none";
9
+ };
10
+ input: {
11
+ readonly options: {};
12
+ readonly forms: readonly [{
13
+ readonly id: "default";
14
+ readonly positionals: readonly [];
15
+ }];
16
+ readonly constraints: readonly [];
17
+ };
18
+ results: import("../results.js").CommandResult[];
2
19
  run: (args: string[]) => void;
3
20
  help: string;
4
21
  };
@@ -1,18 +1,30 @@
1
+ import { jsonResult } from "../results.js";
1
2
  import { parseArgs } from "node:util";
2
3
  import { reindex } from "@zinn-dev/core";
3
4
  import { reportLockWait } from "../database.js";
5
+ import { generateCommandUsage, noInput } from "../input.js";
4
6
  import { output, validatePositionals } from "../lib.js";
5
7
  export const reindexCommand = {
8
+ summary: "Rebuild the search index that `zinn task search` uses from the tasks and their comments, archived tasks included.",
9
+ effects: { domain: "none", storage: "reindex" },
10
+ confirmation: { kind: "none" },
11
+ input: noInput,
12
+ results: [jsonResult("Reindex")],
6
13
  run: (args) => {
7
- const { positionals } = parseArgs({ args, strict: true, allowPositionals: true });
8
- validatePositionals(positionals, []);
14
+ const { positionals } = parseArgs({
15
+ options: noInput.options,
16
+ args,
17
+ strict: true,
18
+ allowPositionals: true,
19
+ });
20
+ validatePositionals(positionals, noInput.forms[0]);
9
21
  const result = reindex.run({ onWait: reportLockWait });
10
22
  output(result, (r) => {
11
23
  const noun = r.taskCount === 1 ? "task" : "tasks";
12
24
  return `Rebuilt the search index from ${r.taskCount} ${noun}`;
13
25
  });
14
26
  },
15
- help: `Usage: zinn reindex
27
+ help: `${generateCommandUsage("reindex", noInput)}
16
28
 
17
29
  Rebuild the search index that \`zinn task search\` uses from the tasks and their comments, archived tasks included.
18
30