@zinn-dev/cli 0.26.0 → 0.28.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/README.md +4 -2
- package/index.ts +11 -38
- package/package.json +2 -2
- package/src/routes/label-router.ts +16 -13
- package/src/routes/project-router.ts +76 -67
- package/src/routes/relation-router.ts +30 -30
- package/src/routes/router.ts +25 -8
- package/src/routes/task-router.ts +116 -114
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ zinn task edit MDR-1 --add-label review --remove-label urgent
|
|
|
140
140
|
|
|
141
141
|
For adding or removing multiple labels at the same time, repeat `--label` on creation, or `--add-label` and `--remove-label` while editing for each label.
|
|
142
142
|
Each value is considered as the label name: `--label "needs review"`, so if you have commas, then they are considered parts of names.
|
|
143
|
-
Label names are case-
|
|
143
|
+
Label names preserve their stored casing, but matching and uniqueness are case-insensitive. For example, `BUG` can match to a label stored as `Bug`, `Bug` or `bug`, but all three canno exist at the same time as three different label entries. Changing only the casing of an existing label is allowed. Whitespace around label names is trimmed.
|
|
144
144
|
|
|
145
145
|
Descriptions default to an empty string and the label colors default to white. Available colors are _red_, _green_, _yellow_, _blue_, _magenta_, _cyan_, _white_, and _gray_.
|
|
146
146
|
|
|
@@ -317,7 +317,9 @@ Use `none` to clear priority. Omitting `--priority` on edits preserves it. Task
|
|
|
317
317
|
|
|
318
318
|
## Activity
|
|
319
319
|
|
|
320
|
-
Zinn keeps an activity log of changes
|
|
320
|
+
Zinn keeps an activity log of task changes such as creating, editing, moving, reordering, archiving, unarchiving and deleting a task, its labels, its relations, and its comments. Project, column, and global label definition changes are recorded too. Each log also says _who_ made the change.
|
|
321
|
+
|
|
322
|
+
Deleting a project records one project deletion rather than separate deletion activity for every cascaded row.
|
|
321
323
|
Note that this data is not yet surfaced by any command yet.
|
|
322
324
|
|
|
323
325
|
When a coding agent performs a mutation with `zinn`, the change is recorded under that agent's name.
|
package/index.ts
CHANGED
|
@@ -8,8 +8,13 @@ const isVersionRequest = args.length === 1 && ["-v", "--version"].includes(args[
|
|
|
8
8
|
|
|
9
9
|
if (isVersionRequest) {
|
|
10
10
|
console.info(packageJson.version);
|
|
11
|
-
} else
|
|
12
|
-
|
|
11
|
+
} else {
|
|
12
|
+
const { createRouter } = await import("./src/routes/router");
|
|
13
|
+
const { routes } = await import("./src/routes/routes");
|
|
14
|
+
const router = createRouter(routes);
|
|
15
|
+
|
|
16
|
+
if (args.length === 0 || isHelpFlag(args[0]!)) {
|
|
17
|
+
console.info(`ZINN - A kanban workflow in the terminal
|
|
13
18
|
|
|
14
19
|
Usage: zinn <command>
|
|
15
20
|
|
|
@@ -19,43 +24,11 @@ Options:
|
|
|
19
24
|
--json Print command output as JSON
|
|
20
25
|
|
|
21
26
|
Commands:
|
|
22
|
-
|
|
23
|
-
project list
|
|
24
|
-
project view
|
|
25
|
-
project delete
|
|
26
|
-
project column create
|
|
27
|
-
project column edit
|
|
28
|
-
project column list
|
|
29
|
-
project column order
|
|
30
|
-
task create
|
|
31
|
-
task list
|
|
32
|
-
task search
|
|
33
|
-
task view
|
|
34
|
-
task edit
|
|
35
|
-
task move
|
|
36
|
-
task order
|
|
37
|
-
task archive
|
|
38
|
-
task unarchive
|
|
39
|
-
task delete
|
|
40
|
-
task relation create
|
|
41
|
-
task relation list
|
|
42
|
-
task relation delete
|
|
43
|
-
task comment create
|
|
44
|
-
task comment list
|
|
45
|
-
task comment edit
|
|
46
|
-
task comment delete
|
|
47
|
-
task label add
|
|
48
|
-
task label remove
|
|
49
|
-
label create
|
|
50
|
-
label edit
|
|
51
|
-
label list
|
|
52
|
-
label delete
|
|
27
|
+
${router.commands}
|
|
53
28
|
|
|
54
29
|
Run zinn <namespace> --help or zinn <command> --help for more information.
|
|
55
30
|
Running zinn without a command shows this help.`);
|
|
56
|
-
} else {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const router = createRouter(routes);
|
|
60
|
-
router.route(args);
|
|
31
|
+
} else {
|
|
32
|
+
router.route(args);
|
|
33
|
+
}
|
|
61
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinn-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "A kanban workflow in the terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@zinn-dev/core": "0.
|
|
45
|
+
"@zinn-dev/core": "0.19.0"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -45,17 +45,27 @@ export const labelRouter = {
|
|
|
45
45
|
validateUniqueOptions(tokens);
|
|
46
46
|
|
|
47
47
|
const input = labelCreateSchema.parse({ name: positionals[0], ...values });
|
|
48
|
-
const created = label.create(input);
|
|
48
|
+
const created = label.create(input, currentActor());
|
|
49
49
|
|
|
50
50
|
output(presentLabel(created), formatLabel);
|
|
51
51
|
},
|
|
52
52
|
help: `Usage: zinn label create <name> [--description <text>] [--color <color>]
|
|
53
53
|
|
|
54
|
-
Create a global label. Names
|
|
54
|
+
Create a global label. Names preserve casing, but uniqueness is case-insensitive.
|
|
55
|
+
Names are trimmed and cannot be blank.
|
|
55
56
|
Description defaults to an empty string; color defaults to white.
|
|
56
57
|
Colors: red, green, yellow, blue, magenta, cyan, white, gray.
|
|
57
58
|
|
|
58
59
|
Example: zinn label create bug --description "Unexpected behavior" --color red`,
|
|
60
|
+
},
|
|
61
|
+
list: {
|
|
62
|
+
run: (args) => {
|
|
63
|
+
parseArgs({ args, strict: true, allowPositionals: false });
|
|
64
|
+
output(label.getAll().map(presentLabel), (labels) => labels.map(formatLabel).join("\n"));
|
|
65
|
+
},
|
|
66
|
+
help: `Usage: zinn label list
|
|
67
|
+
|
|
68
|
+
List all global label definitions.`,
|
|
59
69
|
},
|
|
60
70
|
edit: {
|
|
61
71
|
run: (args) => {
|
|
@@ -75,7 +85,7 @@ Example: zinn label create bug --description "Unexpected behavior" --color red`,
|
|
|
75
85
|
validateUniqueOptions(tokens);
|
|
76
86
|
|
|
77
87
|
const input = labelEditSchema.parse({ labelName: positionals[0], ...values });
|
|
78
|
-
const edited = label.edit(input);
|
|
88
|
+
const edited = label.edit(input, currentActor());
|
|
79
89
|
|
|
80
90
|
output(presentLabel(edited), formatLabel);
|
|
81
91
|
},
|
|
@@ -84,19 +94,11 @@ Example: zinn label create bug --description "Unexpected behavior" --color red`,
|
|
|
84
94
|
Change specified fields.
|
|
85
95
|
Provide at least one edit flag. Use --description "" for an empty description.
|
|
86
96
|
|
|
87
|
-
Names are case-
|
|
97
|
+
Names are matched and kept unique case-insensitively while preserving their casing.
|
|
98
|
+
Names are trimmed. Changing only the casing is allowed.
|
|
88
99
|
Editing does not affect task attachments or task timestamps.
|
|
89
100
|
|
|
90
101
|
Example: zinn label edit bug --name defect --color yellow`,
|
|
91
|
-
},
|
|
92
|
-
list: {
|
|
93
|
-
run: (args) => {
|
|
94
|
-
parseArgs({ args, strict: true, allowPositionals: false });
|
|
95
|
-
output(label.getAll().map(presentLabel), (labels) => labels.map(formatLabel).join("\n"));
|
|
96
|
-
},
|
|
97
|
-
help: `Usage: zinn label list
|
|
98
|
-
|
|
99
|
-
List all global label definitions.`,
|
|
100
102
|
},
|
|
101
103
|
delete: {
|
|
102
104
|
run: (args) => {
|
|
@@ -133,6 +135,7 @@ List all global label definitions.`,
|
|
|
133
135
|
|
|
134
136
|
Delete a label definition and remove it from all tasks after confirmation.
|
|
135
137
|
To remove a label from just one task, use zinn task label remove.
|
|
138
|
+
Label names are matched case-insensitively.
|
|
136
139
|
|
|
137
140
|
Use --yes to skip the confirmation prompt, for example in scripts or with --json.`,
|
|
138
141
|
},
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
validateUniqueOptions,
|
|
13
13
|
} from "../lib";
|
|
14
14
|
import { formatTaskList, presentTask } from "../presentation/task-presentation";
|
|
15
|
+
import { currentActor } from "../actor";
|
|
15
16
|
|
|
16
17
|
type PresentedProject = { key: string; name: string };
|
|
17
18
|
type PresentedProjectView = PresentedProject & { tasks: Array<PresentedTask> };
|
|
@@ -37,43 +38,6 @@ function formatColumn(presented: PresentedColumn) {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export const projectRouter = {
|
|
40
|
-
edit: {
|
|
41
|
-
run: (args) => {
|
|
42
|
-
const { values, positionals, tokens } = parseArgs({
|
|
43
|
-
args,
|
|
44
|
-
options: { name: { type: "string" } },
|
|
45
|
-
allowPositionals: true,
|
|
46
|
-
strict: true,
|
|
47
|
-
tokens: true,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const projectKey = positionals[0];
|
|
51
|
-
|
|
52
|
-
if (projectKey == null) {
|
|
53
|
-
quit("Project key must be specified");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
validatePositionalCount(positionals, 1, "Only one project key can be specified");
|
|
57
|
-
|
|
58
|
-
validateUniqueOptions(tokens);
|
|
59
|
-
|
|
60
|
-
if (values.name === undefined) {
|
|
61
|
-
quit("Provide an edit flag: --name");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const editedProject = project.edit({ projectKey, name: values.name });
|
|
65
|
-
output(presentProject(editedProject), formatProject);
|
|
66
|
-
},
|
|
67
|
-
help: `Usage: zinn project edit <project-key> --name <text>
|
|
68
|
-
|
|
69
|
-
Change the project name.
|
|
70
|
-
The --name flag is required.
|
|
71
|
-
|
|
72
|
-
Unchanged names leave the modification timestamp unchanged.
|
|
73
|
-
|
|
74
|
-
Example: zinn project edit MDR --name "Macrodata Refinement"`,
|
|
75
|
-
},
|
|
76
|
-
|
|
77
41
|
create: {
|
|
78
42
|
run: (args: Array<string>) => {
|
|
79
43
|
const { values, positionals, tokens } = parseArgs({
|
|
@@ -95,7 +59,7 @@ Example: zinn project edit MDR --name "Macrodata Refinement"`,
|
|
|
95
59
|
validateUniqueOptions(tokens);
|
|
96
60
|
|
|
97
61
|
try {
|
|
98
|
-
const createdProject = project.create({ key: projectKey, name: values.name });
|
|
62
|
+
const createdProject = project.create({ key: projectKey, name: values.name }, currentActor());
|
|
99
63
|
output(presentProject(createdProject), formatProject);
|
|
100
64
|
} catch (err: any) {
|
|
101
65
|
quit(err?.message ?? "Something went wrong");
|
|
@@ -165,6 +129,42 @@ Example: zinn project list`,
|
|
|
165
129
|
Show a project and its active tasks in board order.
|
|
166
130
|
|
|
167
131
|
Example: zinn project view MDR`,
|
|
132
|
+
},
|
|
133
|
+
edit: {
|
|
134
|
+
run: (args) => {
|
|
135
|
+
const { values, positionals, tokens } = parseArgs({
|
|
136
|
+
args,
|
|
137
|
+
options: { name: { type: "string" } },
|
|
138
|
+
allowPositionals: true,
|
|
139
|
+
strict: true,
|
|
140
|
+
tokens: true,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const projectKey = positionals[0];
|
|
144
|
+
|
|
145
|
+
if (projectKey == null) {
|
|
146
|
+
quit("Project key must be specified");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
validatePositionalCount(positionals, 1, "Only one project key can be specified");
|
|
150
|
+
|
|
151
|
+
validateUniqueOptions(tokens);
|
|
152
|
+
|
|
153
|
+
if (values.name === undefined) {
|
|
154
|
+
quit("Provide an edit flag: --name");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const editedProject = project.edit({ projectKey, name: values.name }, currentActor());
|
|
158
|
+
output(presentProject(editedProject), formatProject);
|
|
159
|
+
},
|
|
160
|
+
help: `Usage: zinn project edit <project-key> --name <text>
|
|
161
|
+
|
|
162
|
+
Change the project name.
|
|
163
|
+
The --name flag is required.
|
|
164
|
+
|
|
165
|
+
Unchanged names leave the modification timestamp unchanged.
|
|
166
|
+
|
|
167
|
+
Example: zinn project edit MDR --name "Macrodata Refinement"`,
|
|
168
168
|
},
|
|
169
169
|
delete: {
|
|
170
170
|
run: (args: Array<string>) => {
|
|
@@ -193,7 +193,7 @@ Example: zinn project view MDR`,
|
|
|
193
193
|
);
|
|
194
194
|
|
|
195
195
|
if (canDelete) {
|
|
196
|
-
const deletedProject = project.delete(projectKey);
|
|
196
|
+
const deletedProject = project.delete(projectKey, currentActor());
|
|
197
197
|
output(presentProject(deletedProject), (p) => `Deleted ${formatProject(p)}`);
|
|
198
198
|
} else {
|
|
199
199
|
output(presentProject(projectMatch), (p) => `Deletion cancelled for ${formatProject(p)}`);
|
|
@@ -220,7 +220,7 @@ Example: zinn project delete MDR`,
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
try {
|
|
223
|
-
const createdColumn = column.create({ projectKey, name: columnName });
|
|
223
|
+
const createdColumn = column.create({ projectKey, name: columnName }, currentActor());
|
|
224
224
|
output(presentColumn(createdColumn), formatColumn);
|
|
225
225
|
} catch (err: any) {
|
|
226
226
|
quit(err?.message ?? "Something went wrong");
|
|
@@ -232,6 +232,24 @@ Add a column at the end of a project's board.
|
|
|
232
232
|
Names are trimmed, must contain printable text on a single line, and must be unique within the project regardless of casing.
|
|
233
233
|
|
|
234
234
|
Example: zinn project column create MDR "Boardlog"`,
|
|
235
|
+
},
|
|
236
|
+
list: {
|
|
237
|
+
run: (args: Array<string>) => {
|
|
238
|
+
const projectKey = args[0];
|
|
239
|
+
if (projectKey == null) {
|
|
240
|
+
quit("Project key needs to be specified to list columns");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// TODO: attach per-column task count
|
|
244
|
+
// TODO: terminal formatting
|
|
245
|
+
const columns = column.getAllByProjectKey(projectKey).map((c) => ({ name: c.name }));
|
|
246
|
+
output(columns, (presentedColumns) => presentedColumns.map((c) => c.name).join("\n"));
|
|
247
|
+
},
|
|
248
|
+
help: `Usage: zinn project column list <project-key>
|
|
249
|
+
|
|
250
|
+
List a project's columns in board order.
|
|
251
|
+
|
|
252
|
+
Example: zinn project column list MDR`,
|
|
235
253
|
},
|
|
236
254
|
edit: {
|
|
237
255
|
run: (args: Array<string>) => {
|
|
@@ -254,11 +272,14 @@ Example: zinn project column create MDR "Boardlog"`,
|
|
|
254
272
|
quit("Provide an edit flag: --name");
|
|
255
273
|
}
|
|
256
274
|
|
|
257
|
-
const editedColumn = column.edit(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
275
|
+
const editedColumn = column.edit(
|
|
276
|
+
{
|
|
277
|
+
projectKey: positionals[0]!,
|
|
278
|
+
columnName: positionals[1]!,
|
|
279
|
+
name: values.name,
|
|
280
|
+
},
|
|
281
|
+
currentActor(),
|
|
282
|
+
);
|
|
262
283
|
output(presentColumn(editedColumn), formatColumn);
|
|
263
284
|
},
|
|
264
285
|
help: `Usage: zinn project column edit <project-key> <column-name> --name <text>
|
|
@@ -297,7 +318,10 @@ Example: zinn project column edit MDR "In Progress" --name "Refining"`,
|
|
|
297
318
|
quit("Only one target column can be specified");
|
|
298
319
|
}
|
|
299
320
|
|
|
300
|
-
orderedColumn = column.order(
|
|
321
|
+
orderedColumn = column.order(
|
|
322
|
+
{ projectKey, columnName, direction, targetColumnName },
|
|
323
|
+
currentActor(),
|
|
324
|
+
);
|
|
301
325
|
break;
|
|
302
326
|
}
|
|
303
327
|
case "first":
|
|
@@ -308,7 +332,10 @@ Example: zinn project column edit MDR "In Progress" --name "Refining"`,
|
|
|
308
332
|
quit(`Order direction "${direction}" does not accept a target column`);
|
|
309
333
|
}
|
|
310
334
|
|
|
311
|
-
orderedColumn = column.order(
|
|
335
|
+
orderedColumn = column.order(
|
|
336
|
+
{ projectKey, columnName, direction },
|
|
337
|
+
currentActor(),
|
|
338
|
+
);
|
|
312
339
|
break;
|
|
313
340
|
}
|
|
314
341
|
default:
|
|
@@ -318,8 +345,8 @@ Example: zinn project column edit MDR "In Progress" --name "Refining"`,
|
|
|
318
345
|
// TODO: maybe also print the new full column state?
|
|
319
346
|
output(presentColumn(orderedColumn), formatColumn);
|
|
320
347
|
},
|
|
321
|
-
help: `Usage: zinn project column order <project-key> <column-name>
|
|
322
|
-
zinn project column order <project-key> <column-name>
|
|
348
|
+
help: `Usage: zinn project column order <project-key> <column-name> {first|previous|next|last}
|
|
349
|
+
zinn project column order <project-key> <column-name> {before|after} <target-column-name>
|
|
323
350
|
|
|
324
351
|
Change a column's position on the project's board.
|
|
325
352
|
Use first or last for either end, previous or next for one position,
|
|
@@ -329,23 +356,5 @@ Columns are matched by name, and matching is case-insensitive.
|
|
|
329
356
|
|
|
330
357
|
Example: zinn project column order MDR Review before "In Progress"`,
|
|
331
358
|
},
|
|
332
|
-
list: {
|
|
333
|
-
run: (args: Array<string>) => {
|
|
334
|
-
const projectKey = args[0];
|
|
335
|
-
if (projectKey == null) {
|
|
336
|
-
quit("Project key needs to be specified to list columns");
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// TODO: attach per-column task count
|
|
340
|
-
// TODO: terminal formatting
|
|
341
|
-
const columns = column.getAllByProjectKey(projectKey).map((c) => ({ name: c.name }));
|
|
342
|
-
output(columns, (presentedColumns) => presentedColumns.map((c) => c.name).join("\n"));
|
|
343
|
-
},
|
|
344
|
-
help: `Usage: zinn project column list <project-key>
|
|
345
|
-
|
|
346
|
-
List a project's columns in board order.
|
|
347
|
-
|
|
348
|
-
Example: zinn project column list MDR`,
|
|
349
|
-
},
|
|
350
359
|
},
|
|
351
360
|
} satisfies RouteDef;
|
|
@@ -94,36 +94,6 @@ function parseRelationArgs(args: string[]) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export const relationRouter = {
|
|
97
|
-
delete: {
|
|
98
|
-
run: (args) => {
|
|
99
|
-
const props = parseRelationArgs(args);
|
|
100
|
-
relation.delete(props, currentActor());
|
|
101
|
-
|
|
102
|
-
const source = task.getByKey(props.sourceTaskKey);
|
|
103
|
-
const target = task.getByKey(props.targetTaskKey);
|
|
104
|
-
const deleted: PresentedRelationChange = {
|
|
105
|
-
type: props.relation_type,
|
|
106
|
-
source: source.key,
|
|
107
|
-
target: target.key,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
output(deleted, (r) => `Deleted ${r.type} relation from ${r.source} to ${r.target}`);
|
|
111
|
-
},
|
|
112
|
-
help: `Usage: zinn task relation delete <source-task-key> <target-task-key> --type <type>
|
|
113
|
-
|
|
114
|
-
Remove only the specified relation. No confirmation is required.
|
|
115
|
-
|
|
116
|
-
Types: related, dependency, duplicate.
|
|
117
|
-
|
|
118
|
-
For related, either task order works.
|
|
119
|
-
For dependency and duplicate, use the creation direction:
|
|
120
|
-
source depends on target, or source is a duplicate of target.
|
|
121
|
-
|
|
122
|
-
Archived and cross-project tasks are supported.
|
|
123
|
-
A missing relation is an error.
|
|
124
|
-
|
|
125
|
-
Example: zinn task relation delete APP-1 APP-2 --type dependency`,
|
|
126
|
-
},
|
|
127
97
|
create: {
|
|
128
98
|
run: (args) => {
|
|
129
99
|
const props = parseRelationArgs(args);
|
|
@@ -175,4 +145,34 @@ An empty list prints nothing.
|
|
|
175
145
|
|
|
176
146
|
Example: zinn task relation list APP-1`,
|
|
177
147
|
},
|
|
148
|
+
delete: {
|
|
149
|
+
run: (args) => {
|
|
150
|
+
const props = parseRelationArgs(args);
|
|
151
|
+
relation.delete(props, currentActor());
|
|
152
|
+
|
|
153
|
+
const source = task.getByKey(props.sourceTaskKey);
|
|
154
|
+
const target = task.getByKey(props.targetTaskKey);
|
|
155
|
+
const deleted: PresentedRelationChange = {
|
|
156
|
+
type: props.relation_type,
|
|
157
|
+
source: source.key,
|
|
158
|
+
target: target.key,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
output(deleted, (r) => `Deleted ${r.type} relation from ${r.source} to ${r.target}`);
|
|
162
|
+
},
|
|
163
|
+
help: `Usage: zinn task relation delete <source-task-key> <target-task-key> --type <type>
|
|
164
|
+
|
|
165
|
+
Remove only the specified relation. No confirmation is required.
|
|
166
|
+
|
|
167
|
+
Types: related, dependency, duplicate.
|
|
168
|
+
|
|
169
|
+
For related, either task order works.
|
|
170
|
+
For dependency and duplicate, use the creation direction:
|
|
171
|
+
source depends on target, or source is a duplicate of target.
|
|
172
|
+
|
|
173
|
+
Archived and cross-project tasks are supported.
|
|
174
|
+
A missing relation is an error.
|
|
175
|
+
|
|
176
|
+
Example: zinn task relation delete APP-1 APP-2 --type dependency`,
|
|
177
|
+
},
|
|
178
178
|
} satisfies RouteDef;
|
package/src/routes/router.ts
CHANGED
|
@@ -10,18 +10,32 @@ function toCommand(args: Array<string>) {
|
|
|
10
10
|
return args.join(" ");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// Groups sibling commands into one line, e.g. " comment {create|list|edit|delete}".
|
|
14
|
+
function formatCommands(parsedRoutes: Array<ParsedRoute>, prefix: string) {
|
|
15
|
+
const siblingsByParent = new Map<string, Array<string>>();
|
|
16
|
+
for (const { command } of parsedRoutes) {
|
|
17
|
+
if (!command.startsWith(prefix)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const words = command.slice(prefix.length).split(" ");
|
|
22
|
+
const parent = toCommand(words.slice(0, -1));
|
|
23
|
+
siblingsByParent.set(parent, [...(siblingsByParent.get(parent) ?? []), words.at(-1)!]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [...siblingsByParent]
|
|
27
|
+
.map(([parent, siblings]) => ` ${parent === "" ? "" : `${parent} `}{${siblings.join("|")}}`)
|
|
28
|
+
.join("\n");
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
function getNamespaceHelp(parsedRoutes: Array<ParsedRoute>, namespace: string) {
|
|
14
|
-
const
|
|
15
|
-
const commands = parsedRoutes
|
|
16
|
-
.map((route) => route.command)
|
|
17
|
-
.filter((command) => command.startsWith(prefix))
|
|
18
|
-
.map((command) => command.slice(prefix.length));
|
|
32
|
+
const commands = formatCommands(parsedRoutes, `${namespace} `);
|
|
19
33
|
|
|
20
|
-
if (commands
|
|
34
|
+
if (commands === "") {
|
|
21
35
|
return null;
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
return `Usage: zinn ${namespace} <command>\n\nCommands:\n${commands
|
|
38
|
+
return `Usage: zinn ${namespace} <command>\n\nCommands:\n${commands}`;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
export function parseRoutes(routesDef: RouteDef, prefix?: string) {
|
|
@@ -114,5 +128,8 @@ function route(parsedRoutes: Array<ParsedRoute>, rawArgs: Array<string>) {
|
|
|
114
128
|
export function createRouter(routesDef: RouteDef) {
|
|
115
129
|
const parsedRoutes = parseRoutes(routesDef);
|
|
116
130
|
|
|
117
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
route: (args: Array<string>) => route(parsedRoutes, args),
|
|
133
|
+
commands: formatCommands(parsedRoutes, ""),
|
|
134
|
+
};
|
|
118
135
|
}
|
|
@@ -24,76 +24,6 @@ import {
|
|
|
24
24
|
const limitPattern = new RegExp(`^${positiveIntegerPattern}$`);
|
|
25
25
|
|
|
26
26
|
export const taskRouter = {
|
|
27
|
-
edit: {
|
|
28
|
-
run: (args) => {
|
|
29
|
-
const { values, positionals, tokens } = parseArgs({
|
|
30
|
-
args,
|
|
31
|
-
options: {
|
|
32
|
-
title: { type: "string" },
|
|
33
|
-
description: { type: "string" },
|
|
34
|
-
priority: { type: "string" },
|
|
35
|
-
"add-label": { type: "string", multiple: true },
|
|
36
|
-
"remove-label": { type: "string", multiple: true },
|
|
37
|
-
},
|
|
38
|
-
allowPositionals: true,
|
|
39
|
-
strict: true,
|
|
40
|
-
tokens: true,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const taskKey = positionals[0];
|
|
44
|
-
|
|
45
|
-
if (taskKey == null) {
|
|
46
|
-
quit("Task key must be specified");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
validatePositionalCount(positionals, 1, "Only one task key can be specified");
|
|
50
|
-
|
|
51
|
-
validateUniqueOptions(tokens, ["add-label", "remove-label"]);
|
|
52
|
-
|
|
53
|
-
const hasEditFlags =
|
|
54
|
-
values.title !== undefined ||
|
|
55
|
-
values.description !== undefined ||
|
|
56
|
-
values.priority !== undefined ||
|
|
57
|
-
values["add-label"] !== undefined ||
|
|
58
|
-
values["remove-label"] !== undefined;
|
|
59
|
-
|
|
60
|
-
if (!hasEditFlags) {
|
|
61
|
-
quit(
|
|
62
|
-
"Provide at least one edit flag: --title, --description, --priority, --add-label, or --remove-label",
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const editedTask = task.edit(
|
|
67
|
-
{
|
|
68
|
-
taskKey,
|
|
69
|
-
title: values.title,
|
|
70
|
-
description: values.description,
|
|
71
|
-
priority: parsePriority(values.priority),
|
|
72
|
-
addLabelNames: values["add-label"],
|
|
73
|
-
removeLabelNames: values["remove-label"],
|
|
74
|
-
},
|
|
75
|
-
currentActor(),
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
output(presentTask(editedTask), formatTask);
|
|
79
|
-
},
|
|
80
|
-
help: `Usage: zinn task edit <task-key> [--title <text>] [--description <text>] [--priority <low|medium|high|urgent|none>] [--add-label <name>] [--remove-label <name>]
|
|
81
|
-
|
|
82
|
-
Change the supplied fields and preserve everything else.
|
|
83
|
-
Use --priority none to clear priority.
|
|
84
|
-
Provide at least one edit flag. Use --description "" for an empty description.
|
|
85
|
-
|
|
86
|
-
Repeat --add-label or --remove-label for multiple existing labels.
|
|
87
|
-
Adding an attached label or removing an unattached label does not do anything.
|
|
88
|
-
Archived tasks can be edited. Unchanged values leave the task unchanged.
|
|
89
|
-
|
|
90
|
-
The same label cannot be both added and removed.
|
|
91
|
-
Titles cannot be blank.
|
|
92
|
-
|
|
93
|
-
Use --title="--example" for text beginning with a dash.
|
|
94
|
-
|
|
95
|
-
Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
|
|
96
|
-
},
|
|
97
27
|
create: {
|
|
98
28
|
run: (args) => {
|
|
99
29
|
const { values, positionals, tokens } = parseArgs({
|
|
@@ -137,11 +67,12 @@ Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
|
|
|
137
67
|
);
|
|
138
68
|
output(presentTask(createdTask), formatTask);
|
|
139
69
|
},
|
|
140
|
-
help: `Usage: zinn task create <project-key> --title <text> [--description <text>] [--priority
|
|
70
|
+
help: `Usage: zinn task create <project-key> --title <text> [--description <text>] [--priority {low|medium|high|urgent|none}] [--label <name>]
|
|
141
71
|
|
|
142
72
|
Create a task in the project's first column.
|
|
143
73
|
Priority defaults to none (unassigned).
|
|
144
74
|
Repeat --label to attach multiple existing labels. Unknown labels are errors.
|
|
75
|
+
Label names are matched case-insensitively.
|
|
145
76
|
Titles cannot be blank. Use --title="--example" for text beginning with a dash.
|
|
146
77
|
|
|
147
78
|
Example: zinn task create MDR --title "Refine the numbers" --description "Meet the quarterly quota" --label urgent`,
|
|
@@ -170,7 +101,7 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
|
|
|
170
101
|
formatTaskList(presentedTasks, { showsStatus: showsAll }),
|
|
171
102
|
);
|
|
172
103
|
},
|
|
173
|
-
help: `Usage: zinn task list [project-key] [--archived
|
|
104
|
+
help: `Usage: zinn task list [<project-key>] [--archived|--all]
|
|
174
105
|
|
|
175
106
|
List active tasks by default.
|
|
176
107
|
Use --archived to list archived tasks or --all to list both.
|
|
@@ -227,7 +158,7 @@ Example: zinn task list MDR --all`,
|
|
|
227
158
|
console.error(`${count} archived ${noun} hidden, use --all to include them`);
|
|
228
159
|
}
|
|
229
160
|
},
|
|
230
|
-
help: `Usage: zinn task search <query> [project-key] [--archived
|
|
161
|
+
help: `Usage: zinn task search <query> [<project-key>] [--archived|--all] [--limit <n>]
|
|
231
162
|
|
|
232
163
|
Search task titles, descriptions, and comments. A comment match lists the task it belongs to.
|
|
233
164
|
Each word matches the start of a word, ignoring case and accents: e.g. "auth" finds "Authentication".
|
|
@@ -283,6 +214,77 @@ Example: zinn task search "refinement quota" MDR --limit 5`,
|
|
|
283
214
|
Show a task with its current column, description, priority, labels, relations, and comments.
|
|
284
215
|
|
|
285
216
|
Example: zinn task view MDR-1`,
|
|
217
|
+
},
|
|
218
|
+
edit: {
|
|
219
|
+
run: (args) => {
|
|
220
|
+
const { values, positionals, tokens } = parseArgs({
|
|
221
|
+
args,
|
|
222
|
+
options: {
|
|
223
|
+
title: { type: "string" },
|
|
224
|
+
description: { type: "string" },
|
|
225
|
+
priority: { type: "string" },
|
|
226
|
+
"add-label": { type: "string", multiple: true },
|
|
227
|
+
"remove-label": { type: "string", multiple: true },
|
|
228
|
+
},
|
|
229
|
+
allowPositionals: true,
|
|
230
|
+
strict: true,
|
|
231
|
+
tokens: true,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const taskKey = positionals[0];
|
|
235
|
+
|
|
236
|
+
if (taskKey == null) {
|
|
237
|
+
quit("Task key must be specified");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
validatePositionalCount(positionals, 1, "Only one task key can be specified");
|
|
241
|
+
|
|
242
|
+
validateUniqueOptions(tokens, ["add-label", "remove-label"]);
|
|
243
|
+
|
|
244
|
+
const hasEditFlags =
|
|
245
|
+
values.title !== undefined ||
|
|
246
|
+
values.description !== undefined ||
|
|
247
|
+
values.priority !== undefined ||
|
|
248
|
+
values["add-label"] !== undefined ||
|
|
249
|
+
values["remove-label"] !== undefined;
|
|
250
|
+
|
|
251
|
+
if (!hasEditFlags) {
|
|
252
|
+
quit(
|
|
253
|
+
"Provide at least one edit flag: --title, --description, --priority, --add-label, or --remove-label",
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const editedTask = task.edit(
|
|
258
|
+
{
|
|
259
|
+
taskKey,
|
|
260
|
+
title: values.title,
|
|
261
|
+
description: values.description,
|
|
262
|
+
priority: parsePriority(values.priority),
|
|
263
|
+
addLabelNames: values["add-label"],
|
|
264
|
+
removeLabelNames: values["remove-label"],
|
|
265
|
+
},
|
|
266
|
+
currentActor(),
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
output(presentTask(editedTask), formatTask);
|
|
270
|
+
},
|
|
271
|
+
help: `Usage: zinn task edit <task-key> [--title <text>] [--description <text>] [--priority {low|medium|high|urgent|none}] [--add-label <name>] [--remove-label <name>]
|
|
272
|
+
|
|
273
|
+
Change the supplied fields and preserve everything else.
|
|
274
|
+
Use --priority none to clear priority.
|
|
275
|
+
Provide at least one edit flag. Use --description "" for an empty description.
|
|
276
|
+
|
|
277
|
+
Repeat --add-label or --remove-label for multiple existing labels.
|
|
278
|
+
Label names are matched case-insensitively.
|
|
279
|
+
Adding an attached label or removing an unattached label does not do anything.
|
|
280
|
+
Archived tasks can be edited. Unchanged values leave the task unchanged.
|
|
281
|
+
|
|
282
|
+
The same label cannot be both added and removed.
|
|
283
|
+
Titles cannot be blank.
|
|
284
|
+
|
|
285
|
+
Use --title="--example" for text beginning with a dash.
|
|
286
|
+
|
|
287
|
+
Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
|
|
286
288
|
},
|
|
287
289
|
move: {
|
|
288
290
|
run: (args) => {
|
|
@@ -355,14 +357,48 @@ Example: zinn task move MDR-1 "In Progress"`,
|
|
|
355
357
|
quit(`Unknown order direction "${direction}"`);
|
|
356
358
|
}
|
|
357
359
|
},
|
|
358
|
-
help: `Usage: zinn task order <task-key>
|
|
359
|
-
zinn task order <task-key>
|
|
360
|
+
help: `Usage: zinn task order <task-key> {top|up|down|bottom}
|
|
361
|
+
zinn task order <task-key> {before|after} <target-task-key>
|
|
360
362
|
|
|
361
363
|
Change a task's position within its current column.
|
|
362
364
|
Use top or bottom for either end, up or down for one position,
|
|
363
365
|
or before or after to place it relative to another task.
|
|
364
366
|
|
|
365
367
|
Example: zinn task order MDR-2 before MDR-1`,
|
|
368
|
+
},
|
|
369
|
+
archive: {
|
|
370
|
+
run: (args: Array<string>) => {
|
|
371
|
+
const taskKey = args[0];
|
|
372
|
+
|
|
373
|
+
if (taskKey == null) {
|
|
374
|
+
quit("Task key must be specified");
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const archivedTask = task.archive(taskKey, currentActor());
|
|
378
|
+
output(presentTask(archivedTask), formatTaskWithStatus);
|
|
379
|
+
},
|
|
380
|
+
help: `Usage: zinn task archive <task-key>
|
|
381
|
+
|
|
382
|
+
Archive a task so it no longer appears in active task lists.
|
|
383
|
+
|
|
384
|
+
Example: zinn task archive MDR-1`,
|
|
385
|
+
},
|
|
386
|
+
unarchive: {
|
|
387
|
+
run: (args: Array<string>) => {
|
|
388
|
+
const taskKey = args[0];
|
|
389
|
+
|
|
390
|
+
if (taskKey == null) {
|
|
391
|
+
quit("Task key must be specified");
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const unarchivedTask = task.unarchive(taskKey, currentActor());
|
|
395
|
+
output(presentTask(unarchivedTask), formatTaskWithStatus);
|
|
396
|
+
},
|
|
397
|
+
help: `Usage: zinn task unarchive <task-key>
|
|
398
|
+
|
|
399
|
+
Unarchive a task at the bottom of its previous column.
|
|
400
|
+
|
|
401
|
+
Example: zinn task unarchive MDR-1`,
|
|
366
402
|
},
|
|
367
403
|
delete: {
|
|
368
404
|
run: (args: Array<string>) => {
|
|
@@ -402,40 +438,6 @@ Permanently delete a task after confirmation.
|
|
|
402
438
|
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
403
439
|
|
|
404
440
|
Example: zinn task delete MDR-1`,
|
|
405
|
-
},
|
|
406
|
-
archive: {
|
|
407
|
-
run: (args: Array<string>) => {
|
|
408
|
-
const taskKey = args[0];
|
|
409
|
-
|
|
410
|
-
if (taskKey == null) {
|
|
411
|
-
quit("Task key must be specified");
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const archivedTask = task.archive(taskKey, currentActor());
|
|
415
|
-
output(presentTask(archivedTask), formatTaskWithStatus);
|
|
416
|
-
},
|
|
417
|
-
help: `Usage: zinn task archive <task-key>
|
|
418
|
-
|
|
419
|
-
Archive a task so it no longer appears in active task lists.
|
|
420
|
-
|
|
421
|
-
Example: zinn task archive MDR-1`,
|
|
422
|
-
},
|
|
423
|
-
unarchive: {
|
|
424
|
-
run: (args: Array<string>) => {
|
|
425
|
-
const taskKey = args[0];
|
|
426
|
-
|
|
427
|
-
if (taskKey == null) {
|
|
428
|
-
quit("Task key must be specified");
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const unarchivedTask = task.unarchive(taskKey, currentActor());
|
|
432
|
-
output(presentTask(unarchivedTask), formatTaskWithStatus);
|
|
433
|
-
},
|
|
434
|
-
help: `Usage: zinn task unarchive <task-key>
|
|
435
|
-
|
|
436
|
-
Unarchive a task at the bottom of its previous column.
|
|
437
|
-
|
|
438
|
-
Example: zinn task unarchive MDR-1`,
|
|
439
441
|
},
|
|
440
442
|
relation: relationRouter,
|
|
441
443
|
comment: commentRouter,
|
|
@@ -445,19 +447,19 @@ Example: zinn task unarchive MDR-1`,
|
|
|
445
447
|
const props = parseTaskLabelArgs(args);
|
|
446
448
|
output(presentTask(task.label.add(props, currentActor())), formatTask);
|
|
447
449
|
},
|
|
448
|
-
help: `Usage: zinn task label add <task-key> <label-name
|
|
450
|
+
help: `Usage: zinn task label add <task-key> <label-name>...
|
|
449
451
|
|
|
450
|
-
Add existing labels to a task.
|
|
452
|
+
Add existing labels to a task. Label names are matched case-insensitively.
|
|
453
|
+
Already attached labels are unchanged.`,
|
|
451
454
|
},
|
|
452
455
|
remove: {
|
|
453
456
|
run: (args) => {
|
|
454
457
|
const props = parseTaskLabelArgs(args);
|
|
455
458
|
output(presentTask(task.label.remove(props, currentActor())), formatTask);
|
|
456
459
|
},
|
|
457
|
-
help: `Usage: zinn task label remove <task-key> <label-name
|
|
460
|
+
help: `Usage: zinn task label remove <task-key> <label-name>...
|
|
458
461
|
|
|
459
|
-
Remove existing labels from a task.
|
|
460
|
-
Label definitions are preserved.`,
|
|
462
|
+
Remove existing labels from a task. Label names are matched case-insensitively.`,
|
|
461
463
|
},
|
|
462
464
|
},
|
|
463
465
|
} satisfies RouteDef;
|