@zinn-dev/cli 0.24.0 → 0.26.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 +32 -4
- package/index.ts +2 -2
- package/package.json +1 -1
- package/src/lib.ts +6 -3
- package/src/routes/comment-router.ts +12 -3
- package/src/routes/label-router.ts +14 -3
- package/src/routes/project-router.ts +10 -2
- package/src/routes/task-router.ts +13 -3
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
|
|
|
@@ -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
|
@@ -4,7 +4,7 @@ import { isHelpFlag } from "./src/lib";
|
|
|
4
4
|
import packageJson from "./package.json";
|
|
5
5
|
|
|
6
6
|
const args = process.argv.slice(2);
|
|
7
|
-
const isVersionRequest = args.length === 1 &&
|
|
7
|
+
const isVersionRequest = args.length === 1 && ["-v", "--version"].includes(args[0]!);
|
|
8
8
|
|
|
9
9
|
if (isVersionRequest) {
|
|
10
10
|
console.info(packageJson.version);
|
|
@@ -15,7 +15,7 @@ Usage: zinn <command>
|
|
|
15
15
|
|
|
16
16
|
Options:
|
|
17
17
|
-h, --help Show help
|
|
18
|
-
--version
|
|
18
|
+
-v, --version Show version
|
|
19
19
|
--json Print command output as JSON
|
|
20
20
|
|
|
21
21
|
Commands:
|
package/package.json
CHANGED
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
|
},
|
|
@@ -100,8 +100,15 @@ List all global label definitions.`,
|
|
|
100
100
|
},
|
|
101
101
|
delete: {
|
|
102
102
|
run: (args) => {
|
|
103
|
-
const { positionals } = parseArgs({
|
|
103
|
+
const { values, positionals } = parseArgs({
|
|
104
|
+
args,
|
|
105
|
+
options: { yes: { type: "boolean" } },
|
|
106
|
+
strict: true,
|
|
107
|
+
allowPositionals: true,
|
|
108
|
+
});
|
|
109
|
+
|
|
104
110
|
validatePositionalCount(positionals, 1, "Exactly one label name is required");
|
|
111
|
+
|
|
105
112
|
const props = labelDeleteSchema.parse({ name: positionals[0] });
|
|
106
113
|
const labelMatch = label.getByName(props.name);
|
|
107
114
|
|
|
@@ -111,7 +118,9 @@ List all global label definitions.`,
|
|
|
111
118
|
|
|
112
119
|
const canDelete = confirmAction(
|
|
113
120
|
`Are you sure you want to delete label "${labelMatch.name}" and remove it from all tasks?`,
|
|
121
|
+
values.yes === true,
|
|
114
122
|
);
|
|
123
|
+
|
|
115
124
|
if (!canDelete) {
|
|
116
125
|
output(presentLabel(labelMatch), (l) => `Deletion cancelled for label "${l.name}"`);
|
|
117
126
|
return;
|
|
@@ -120,9 +129,11 @@ List all global label definitions.`,
|
|
|
120
129
|
const deleted = label.delete(props, currentActor());
|
|
121
130
|
output(presentLabel(deleted), (l) => `Deleted label "${l.name}"`);
|
|
122
131
|
},
|
|
123
|
-
help: `Usage: zinn label delete <name>
|
|
132
|
+
help: `Usage: zinn label delete <name> [--yes]
|
|
124
133
|
|
|
125
134
|
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
|
|
135
|
+
To remove a label from just one task, use zinn task label remove.
|
|
136
|
+
|
|
137
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.`,
|
|
127
138
|
},
|
|
128
139
|
} satisfies RouteDef;
|
|
@@ -168,7 +168,13 @@ Example: zinn project view MDR`,
|
|
|
168
168
|
},
|
|
169
169
|
delete: {
|
|
170
170
|
run: (args: Array<string>) => {
|
|
171
|
-
const
|
|
171
|
+
const { values, positionals } = parseArgs({
|
|
172
|
+
args,
|
|
173
|
+
options: { yes: { type: "boolean" } },
|
|
174
|
+
allowPositionals: true,
|
|
175
|
+
strict: true,
|
|
176
|
+
});
|
|
177
|
+
const projectKey = positionals[0];
|
|
172
178
|
|
|
173
179
|
if (projectKey == null) {
|
|
174
180
|
quit("You need to specificy which project to delete");
|
|
@@ -183,6 +189,7 @@ Example: zinn project view MDR`,
|
|
|
183
189
|
|
|
184
190
|
const canDelete = confirmAction(
|
|
185
191
|
`Are you sure you want to delete ${projectMatch.key} and all of its columns and tasks?`,
|
|
192
|
+
values.yes === true,
|
|
186
193
|
);
|
|
187
194
|
|
|
188
195
|
if (canDelete) {
|
|
@@ -195,9 +202,10 @@ Example: zinn project view MDR`,
|
|
|
195
202
|
quit(err?.message ?? "Something went wrong");
|
|
196
203
|
}
|
|
197
204
|
},
|
|
198
|
-
help: `Usage: zinn project delete <project-key>
|
|
205
|
+
help: `Usage: zinn project delete <project-key> [--yes]
|
|
199
206
|
|
|
200
207
|
Permanently delete a project and all of its columns and tasks after confirmation.
|
|
208
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
201
209
|
|
|
202
210
|
Example: zinn project delete MDR`,
|
|
203
211
|
},
|
|
@@ -366,7 +366,13 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
366
366
|
},
|
|
367
367
|
delete: {
|
|
368
368
|
run: (args: Array<string>) => {
|
|
369
|
-
const
|
|
369
|
+
const { values, positionals } = parseArgs({
|
|
370
|
+
args,
|
|
371
|
+
options: { yes: { type: "boolean" } },
|
|
372
|
+
allowPositionals: true,
|
|
373
|
+
strict: true,
|
|
374
|
+
});
|
|
375
|
+
const taskKey = positionals[0];
|
|
370
376
|
|
|
371
377
|
if (taskKey == null) {
|
|
372
378
|
quit("Task key must be specified");
|
|
@@ -374,7 +380,10 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
374
380
|
|
|
375
381
|
try {
|
|
376
382
|
const taskMatch = task.getByKey(taskKey);
|
|
377
|
-
const canDelete = confirmAction(
|
|
383
|
+
const canDelete = confirmAction(
|
|
384
|
+
`Are you sure you want to delete ${taskKey}?`,
|
|
385
|
+
values.yes === true,
|
|
386
|
+
);
|
|
378
387
|
const presented = presentTask(taskMatch);
|
|
379
388
|
|
|
380
389
|
if (canDelete) {
|
|
@@ -387,9 +396,10 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
387
396
|
quit(err?.message ?? "Something went wrong");
|
|
388
397
|
}
|
|
389
398
|
},
|
|
390
|
-
help: `Usage: zinn task delete <task-key>
|
|
399
|
+
help: `Usage: zinn task delete <task-key> [--yes]
|
|
391
400
|
|
|
392
401
|
Permanently delete a task after confirmation.
|
|
402
|
+
Use --yes to skip the confirmation prompt, for example in scripts or with --json.
|
|
393
403
|
|
|
394
404
|
Example: zinn task delete MDR-1`,
|
|
395
405
|
},
|