@zinn-dev/cli 0.25.0 → 0.27.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 +33 -5
- package/index.ts +11 -38
- package/package.json +2 -2
- package/src/lib.ts +6 -3
- package/src/routes/comment-router.ts +12 -3
- package/src/routes/label-router.ts +28 -14
- package/src/routes/project-router.ts +66 -59
- package/src/routes/relation-router.ts +30 -30
- package/src/routes/router.ts +25 -8
- package/src/routes/task-router.ts +121 -109
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Directions follow board order: `first` is the start of the board and `last` is i
|
|
|
75
75
|
Both the column and the target of `before` or `after` are matched by name, and matching is case-insensitive.
|
|
76
76
|
Moving a column to the position it already has, or before or after itself, does nothing. Tasks stay in their columns.
|
|
77
77
|
|
|
78
|
-
`zinn project delete MDR` asks for confirmation, then permanently deletes the project and all of its columns and tasks.
|
|
78
|
+
`zinn project delete MDR` asks for confirmation, then permanently deletes the project and all of its columns and tasks. `--yes` skips the confirmation (see [Confirmations](#confirmations)).
|
|
79
79
|
|
|
80
80
|
## Create and read tasks
|
|
81
81
|
|
|
@@ -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
|
|
|
@@ -153,7 +153,7 @@ Note that label changes also update the task's modification timestamp. Archived
|
|
|
153
153
|
|
|
154
154
|
Commands like `task view` and task mutation output show attached labels.
|
|
155
155
|
|
|
156
|
-
`zinn label delete urgent` asks for confirmation, then deletes the definition and removes it from every task. Declining confirmation leaves the label and its attachments unchanged.
|
|
156
|
+
`zinn label delete urgent` asks for confirmation, then deletes the definition and removes it from every task. Declining confirmation leaves the label and its attachments unchanged. `--yes` skips the confirmation (see [Confirmations](#confirmations)).
|
|
157
157
|
Use `task label remove` to remove a label attachment from one task instead. Task/project deletion cleans up label attachments, but does not affect labels themselves.
|
|
158
158
|
|
|
159
159
|
## Task relations
|
|
@@ -197,7 +197,7 @@ zinn task comment edit MDR-1#1 --text "Approved"
|
|
|
197
197
|
zinn task comment delete MDR-1#1
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
Deletion asks for confirmation. Comments can be added to archived tasks. Comment mutations are recorded in the activity log without changing the task's modification timestamp.
|
|
200
|
+
Deletion asks for confirmation, unless `--yes` is used (see [Confirmations](#confirmations)). Comments can be added to archived tasks. Comment mutations are recorded in the activity log without changing the task's modification timestamp.
|
|
201
201
|
|
|
202
202
|
## Edit tasks
|
|
203
203
|
|
|
@@ -257,7 +257,35 @@ Unarchiving puts a task at the bottom of its previous column:
|
|
|
257
257
|
zinn task unarchive MDR-1
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
Delete a task permanently with `zinn task delete MDR-1`. It asks for confirmation before performing the action.
|
|
260
|
+
Delete a task permanently with `zinn task delete MDR-1`. It asks for confirmation before performing the action, unless `--yes` is used (see [Confirmations](#confirmations)).
|
|
261
|
+
|
|
262
|
+
## Scripting and JSON output
|
|
263
|
+
|
|
264
|
+
Add `--json` to any command to get JSON instead of text. The flag can go anywhere in the command, except after `--`, where it is treated as a regular argument such as searching literally for `--json` in text.
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
zinn task list MDR --json
|
|
268
|
+
zinn task create MDR --title "Refine the numbers" --json
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
- Read commands print what they list or show. Write commands print the entity they created, changed, or deleted.
|
|
272
|
+
- Output is a single JSON document on stdout. Empty lists print `[]`.
|
|
273
|
+
- Errors go to stderr as `{ "error": { "message": "..." } }`, stdout stays empty, and the command exits with code 1.
|
|
274
|
+
|
|
275
|
+
Text output is meant for people. It includes the invisible terminal color codes, so scripts should preferably use `--json` to get reliable output.
|
|
276
|
+
|
|
277
|
+
### Confirmations
|
|
278
|
+
|
|
279
|
+
Commands like `project delete`, `task delete`, etc. ask for confirmation before deleting. Use `--yes` to skip the prompt:
|
|
280
|
+
|
|
281
|
+
```sh
|
|
282
|
+
zinn task delete MDR-1 --yes
|
|
283
|
+
zinn task delete MDR-1 --yes --json
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- With `--json`, `--yes` is **required**. Without it, the command exits with an error and deletes nothing.
|
|
287
|
+
- When nothing answers the prompt, as in CI or with input redirected from an empty source, a delete without `--yes` counts as declined: it prints `Deletion cancelled …` and exits with code 0. Scripts that delete should always use `--yes`.
|
|
288
|
+
- `task relation delete` is consider a low consequence action, so it never asks for confirmation and does not accept `--yes`.
|
|
261
289
|
|
|
262
290
|
## Help
|
|
263
291
|
|
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.27.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.18.0"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/lib.ts
CHANGED
|
@@ -26,10 +26,13 @@ export function output<T>(data: T, transformToString: (data: T) => string) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function confirmAction(message: string) {
|
|
29
|
+
export function confirmAction(message: string, isPreconfirmed: boolean) {
|
|
30
|
+
if (isPreconfirmed) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
if (outputMode === "json") {
|
|
31
|
-
|
|
32
|
-
quit("Commands that ask for confirmation cannot be used with --json yet");
|
|
35
|
+
quit("Commands that ask for confirmation need --yes when used with --json");
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
return confirm(message);
|
|
@@ -122,11 +122,19 @@ Example: zinn task comment edit MDR-1#2 --text "Approved"`,
|
|
|
122
122
|
},
|
|
123
123
|
delete: {
|
|
124
124
|
run: (args) => {
|
|
125
|
-
const { positionals } = parseArgs({
|
|
125
|
+
const { values, positionals } = parseArgs({
|
|
126
|
+
args,
|
|
127
|
+
options: { yes: { type: "boolean" } },
|
|
128
|
+
allowPositionals: true,
|
|
129
|
+
strict: true,
|
|
130
|
+
});
|
|
126
131
|
validatePositionalCount(positionals, 1, "Exactly one comment key is required");
|
|
127
132
|
|
|
128
133
|
const commentMatch = comment.getByKey(positionals[0]!);
|
|
129
|
-
const canDelete = confirmAction(
|
|
134
|
+
const canDelete = confirmAction(
|
|
135
|
+
`Are you sure you want to delete ${commentMatch.key}?`,
|
|
136
|
+
values.yes === true,
|
|
137
|
+
);
|
|
130
138
|
const presented = presentComment(commentMatch);
|
|
131
139
|
|
|
132
140
|
if (!canDelete) {
|
|
@@ -137,9 +145,10 @@ Example: zinn task comment edit MDR-1#2 --text "Approved"`,
|
|
|
137
145
|
comment.delete({ commentKey: commentMatch.key }, currentActor());
|
|
138
146
|
output(presented, (entry) => `Deleted ${entry.key}`);
|
|
139
147
|
},
|
|
140
|
-
help: `Usage: zinn task comment delete <comment-key>
|
|
148
|
+
help: `Usage: zinn task comment delete <comment-key> [--yes]
|
|
141
149
|
|
|
142
150
|
Permanently delete a comment after confirmation.
|
|
151
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
143
152
|
|
|
144
153
|
Example: zinn task comment delete MDR-1#2`,
|
|
145
154
|
},
|
|
@@ -51,11 +51,21 @@ export const labelRouter = {
|
|
|
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) => {
|
|
@@ -84,24 +94,23 @@ 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) => {
|
|
103
|
-
const { positionals } = parseArgs({
|
|
105
|
+
const { values, positionals } = parseArgs({
|
|
106
|
+
args,
|
|
107
|
+
options: { yes: { type: "boolean" } },
|
|
108
|
+
strict: true,
|
|
109
|
+
allowPositionals: true,
|
|
110
|
+
});
|
|
111
|
+
|
|
104
112
|
validatePositionalCount(positionals, 1, "Exactly one label name is required");
|
|
113
|
+
|
|
105
114
|
const props = labelDeleteSchema.parse({ name: positionals[0] });
|
|
106
115
|
const labelMatch = label.getByName(props.name);
|
|
107
116
|
|
|
@@ -111,7 +120,9 @@ List all global label definitions.`,
|
|
|
111
120
|
|
|
112
121
|
const canDelete = confirmAction(
|
|
113
122
|
`Are you sure you want to delete label "${labelMatch.name}" and remove it from all tasks?`,
|
|
123
|
+
values.yes === true,
|
|
114
124
|
);
|
|
125
|
+
|
|
115
126
|
if (!canDelete) {
|
|
116
127
|
output(presentLabel(labelMatch), (l) => `Deletion cancelled for label "${l.name}"`);
|
|
117
128
|
return;
|
|
@@ -120,9 +131,12 @@ List all global label definitions.`,
|
|
|
120
131
|
const deleted = label.delete(props, currentActor());
|
|
121
132
|
output(presentLabel(deleted), (l) => `Deleted label "${l.name}"`);
|
|
122
133
|
},
|
|
123
|
-
help: `Usage: zinn label delete <name>
|
|
134
|
+
help: `Usage: zinn label delete <name> [--yes]
|
|
124
135
|
|
|
125
136
|
Delete a label definition and remove it from all tasks after confirmation.
|
|
126
|
-
To remove a label from just one task, use zinn task label remove
|
|
137
|
+
To remove a label from just one task, use zinn task label remove.
|
|
138
|
+
Label names are matched case-insensitively.
|
|
139
|
+
|
|
140
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.`,
|
|
127
141
|
},
|
|
128
142
|
} satisfies RouteDef;
|
|
@@ -37,43 +37,6 @@ function formatColumn(presented: PresentedColumn) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
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
40
|
create: {
|
|
78
41
|
run: (args: Array<string>) => {
|
|
79
42
|
const { values, positionals, tokens } = parseArgs({
|
|
@@ -165,10 +128,52 @@ Example: zinn project list`,
|
|
|
165
128
|
Show a project and its active tasks in board order.
|
|
166
129
|
|
|
167
130
|
Example: zinn project view MDR`,
|
|
131
|
+
},
|
|
132
|
+
edit: {
|
|
133
|
+
run: (args) => {
|
|
134
|
+
const { values, positionals, tokens } = parseArgs({
|
|
135
|
+
args,
|
|
136
|
+
options: { name: { type: "string" } },
|
|
137
|
+
allowPositionals: true,
|
|
138
|
+
strict: true,
|
|
139
|
+
tokens: true,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const projectKey = positionals[0];
|
|
143
|
+
|
|
144
|
+
if (projectKey == null) {
|
|
145
|
+
quit("Project key must be specified");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
validatePositionalCount(positionals, 1, "Only one project key can be specified");
|
|
149
|
+
|
|
150
|
+
validateUniqueOptions(tokens);
|
|
151
|
+
|
|
152
|
+
if (values.name === undefined) {
|
|
153
|
+
quit("Provide an edit flag: --name");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const editedProject = project.edit({ projectKey, name: values.name });
|
|
157
|
+
output(presentProject(editedProject), formatProject);
|
|
158
|
+
},
|
|
159
|
+
help: `Usage: zinn project edit <project-key> --name <text>
|
|
160
|
+
|
|
161
|
+
Change the project name.
|
|
162
|
+
The --name flag is required.
|
|
163
|
+
|
|
164
|
+
Unchanged names leave the modification timestamp unchanged.
|
|
165
|
+
|
|
166
|
+
Example: zinn project edit MDR --name "Macrodata Refinement"`,
|
|
168
167
|
},
|
|
169
168
|
delete: {
|
|
170
169
|
run: (args: Array<string>) => {
|
|
171
|
-
const
|
|
170
|
+
const { values, positionals } = parseArgs({
|
|
171
|
+
args,
|
|
172
|
+
options: { yes: { type: "boolean" } },
|
|
173
|
+
allowPositionals: true,
|
|
174
|
+
strict: true,
|
|
175
|
+
});
|
|
176
|
+
const projectKey = positionals[0];
|
|
172
177
|
|
|
173
178
|
if (projectKey == null) {
|
|
174
179
|
quit("You need to specificy which project to delete");
|
|
@@ -183,6 +188,7 @@ Example: zinn project view MDR`,
|
|
|
183
188
|
|
|
184
189
|
const canDelete = confirmAction(
|
|
185
190
|
`Are you sure you want to delete ${projectMatch.key} and all of its columns and tasks?`,
|
|
191
|
+
values.yes === true,
|
|
186
192
|
);
|
|
187
193
|
|
|
188
194
|
if (canDelete) {
|
|
@@ -195,9 +201,10 @@ Example: zinn project view MDR`,
|
|
|
195
201
|
quit(err?.message ?? "Something went wrong");
|
|
196
202
|
}
|
|
197
203
|
},
|
|
198
|
-
help: `Usage: zinn project delete <project-key>
|
|
204
|
+
help: `Usage: zinn project delete <project-key> [--yes]
|
|
199
205
|
|
|
200
206
|
Permanently delete a project and all of its columns and tasks after confirmation.
|
|
207
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
201
208
|
|
|
202
209
|
Example: zinn project delete MDR`,
|
|
203
210
|
},
|
|
@@ -224,6 +231,24 @@ Add a column at the end of a project's board.
|
|
|
224
231
|
Names are trimmed, must contain printable text on a single line, and must be unique within the project regardless of casing.
|
|
225
232
|
|
|
226
233
|
Example: zinn project column create MDR "Boardlog"`,
|
|
234
|
+
},
|
|
235
|
+
list: {
|
|
236
|
+
run: (args: Array<string>) => {
|
|
237
|
+
const projectKey = args[0];
|
|
238
|
+
if (projectKey == null) {
|
|
239
|
+
quit("Project key needs to be specified to list columns");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// TODO: attach per-column task count
|
|
243
|
+
// TODO: terminal formatting
|
|
244
|
+
const columns = column.getAllByProjectKey(projectKey).map((c) => ({ name: c.name }));
|
|
245
|
+
output(columns, (presentedColumns) => presentedColumns.map((c) => c.name).join("\n"));
|
|
246
|
+
},
|
|
247
|
+
help: `Usage: zinn project column list <project-key>
|
|
248
|
+
|
|
249
|
+
List a project's columns in board order.
|
|
250
|
+
|
|
251
|
+
Example: zinn project column list MDR`,
|
|
227
252
|
},
|
|
228
253
|
edit: {
|
|
229
254
|
run: (args: Array<string>) => {
|
|
@@ -310,8 +335,8 @@ Example: zinn project column edit MDR "In Progress" --name "Refining"`,
|
|
|
310
335
|
// TODO: maybe also print the new full column state?
|
|
311
336
|
output(presentColumn(orderedColumn), formatColumn);
|
|
312
337
|
},
|
|
313
|
-
help: `Usage: zinn project column order <project-key> <column-name>
|
|
314
|
-
zinn project column order <project-key> <column-name>
|
|
338
|
+
help: `Usage: zinn project column order <project-key> <column-name> {first|previous|next|last}
|
|
339
|
+
zinn project column order <project-key> <column-name> {before|after} <target-column-name>
|
|
315
340
|
|
|
316
341
|
Change a column's position on the project's board.
|
|
317
342
|
Use first or last for either end, previous or next for one position,
|
|
@@ -321,23 +346,5 @@ Columns are matched by name, and matching is case-insensitive.
|
|
|
321
346
|
|
|
322
347
|
Example: zinn project column order MDR Review before "In Progress"`,
|
|
323
348
|
},
|
|
324
|
-
list: {
|
|
325
|
-
run: (args: Array<string>) => {
|
|
326
|
-
const projectKey = args[0];
|
|
327
|
-
if (projectKey == null) {
|
|
328
|
-
quit("Project key needs to be specified to list columns");
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// TODO: attach per-column task count
|
|
332
|
-
// TODO: terminal formatting
|
|
333
|
-
const columns = column.getAllByProjectKey(projectKey).map((c) => ({ name: c.name }));
|
|
334
|
-
output(columns, (presentedColumns) => presentedColumns.map((c) => c.name).join("\n"));
|
|
335
|
-
},
|
|
336
|
-
help: `Usage: zinn project column list <project-key>
|
|
337
|
-
|
|
338
|
-
List a project's columns in board order.
|
|
339
|
-
|
|
340
|
-
Example: zinn project column list MDR`,
|
|
341
|
-
},
|
|
342
349
|
},
|
|
343
350
|
} 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,43 +357,14 @@ 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`,
|
|
366
|
-
},
|
|
367
|
-
delete: {
|
|
368
|
-
run: (args: Array<string>) => {
|
|
369
|
-
const taskKey = args[0];
|
|
370
|
-
|
|
371
|
-
if (taskKey == null) {
|
|
372
|
-
quit("Task key must be specified");
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
try {
|
|
376
|
-
const taskMatch = task.getByKey(taskKey);
|
|
377
|
-
const canDelete = confirmAction(`Are you sure you want to delete ${taskKey}?`);
|
|
378
|
-
const presented = presentTask(taskMatch);
|
|
379
|
-
|
|
380
|
-
if (canDelete) {
|
|
381
|
-
task.delete(taskKey, currentActor());
|
|
382
|
-
output(presented, (t) => `Deleted ${formatTask(t)}`);
|
|
383
|
-
} else {
|
|
384
|
-
output(presented, (t) => `Deletion cancelled for ${formatTask(t)}`);
|
|
385
|
-
}
|
|
386
|
-
} catch (err: any) {
|
|
387
|
-
quit(err?.message ?? "Something went wrong");
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
help: `Usage: zinn task delete <task-key>
|
|
391
|
-
|
|
392
|
-
Permanently delete a task after confirmation.
|
|
393
|
-
|
|
394
|
-
Example: zinn task delete MDR-1`,
|
|
395
368
|
},
|
|
396
369
|
archive: {
|
|
397
370
|
run: (args: Array<string>) => {
|
|
@@ -426,6 +399,45 @@ Example: zinn task archive MDR-1`,
|
|
|
426
399
|
Unarchive a task at the bottom of its previous column.
|
|
427
400
|
|
|
428
401
|
Example: zinn task unarchive MDR-1`,
|
|
402
|
+
},
|
|
403
|
+
delete: {
|
|
404
|
+
run: (args: Array<string>) => {
|
|
405
|
+
const { values, positionals } = parseArgs({
|
|
406
|
+
args,
|
|
407
|
+
options: { yes: { type: "boolean" } },
|
|
408
|
+
allowPositionals: true,
|
|
409
|
+
strict: true,
|
|
410
|
+
});
|
|
411
|
+
const taskKey = positionals[0];
|
|
412
|
+
|
|
413
|
+
if (taskKey == null) {
|
|
414
|
+
quit("Task key must be specified");
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
try {
|
|
418
|
+
const taskMatch = task.getByKey(taskKey);
|
|
419
|
+
const canDelete = confirmAction(
|
|
420
|
+
`Are you sure you want to delete ${taskKey}?`,
|
|
421
|
+
values.yes === true,
|
|
422
|
+
);
|
|
423
|
+
const presented = presentTask(taskMatch);
|
|
424
|
+
|
|
425
|
+
if (canDelete) {
|
|
426
|
+
task.delete(taskKey, currentActor());
|
|
427
|
+
output(presented, (t) => `Deleted ${formatTask(t)}`);
|
|
428
|
+
} else {
|
|
429
|
+
output(presented, (t) => `Deletion cancelled for ${formatTask(t)}`);
|
|
430
|
+
}
|
|
431
|
+
} catch (err: any) {
|
|
432
|
+
quit(err?.message ?? "Something went wrong");
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
help: `Usage: zinn task delete <task-key> [--yes]
|
|
436
|
+
|
|
437
|
+
Permanently delete a task after confirmation.
|
|
438
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
439
|
+
|
|
440
|
+
Example: zinn task delete MDR-1`,
|
|
429
441
|
},
|
|
430
442
|
relation: relationRouter,
|
|
431
443
|
comment: commentRouter,
|
|
@@ -435,19 +447,19 @@ Example: zinn task unarchive MDR-1`,
|
|
|
435
447
|
const props = parseTaskLabelArgs(args);
|
|
436
448
|
output(presentTask(task.label.add(props, currentActor())), formatTask);
|
|
437
449
|
},
|
|
438
|
-
help: `Usage: zinn task label add <task-key> <label-name
|
|
450
|
+
help: `Usage: zinn task label add <task-key> <label-name>...
|
|
439
451
|
|
|
440
|
-
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.`,
|
|
441
454
|
},
|
|
442
455
|
remove: {
|
|
443
456
|
run: (args) => {
|
|
444
457
|
const props = parseTaskLabelArgs(args);
|
|
445
458
|
output(presentTask(task.label.remove(props, currentActor())), formatTask);
|
|
446
459
|
},
|
|
447
|
-
help: `Usage: zinn task label remove <task-key> <label-name
|
|
460
|
+
help: `Usage: zinn task label remove <task-key> <label-name>...
|
|
448
461
|
|
|
449
|
-
Remove existing labels from a task.
|
|
450
|
-
Label definitions are preserved.`,
|
|
462
|
+
Remove existing labels from a task. Label names are matched case-insensitively.`,
|
|
451
463
|
},
|
|
452
464
|
},
|
|
453
465
|
} satisfies RouteDef;
|