@zinn-dev/cli 0.41.0 → 0.42.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 +11 -689
- package/index.js +2 -2
- package/package.json +3 -2
- package/skills/zinn/SKILL.md +1 -1
- package/src/capabilities-schema.d.ts +22 -23
- package/src/capabilities-schema.js +17 -82
- package/src/capabilities.d.ts +11 -3
- package/src/capabilities.js +12 -4
- package/src/column-hint.d.ts +3 -0
- package/src/column-hint.js +225 -0
- package/src/database.js +1 -4
- package/src/errors.js +2 -0
- package/src/input.d.ts +154 -43
- package/src/input.js +86 -13
- package/src/lib.d.ts +30 -2
- package/src/lib.js +74 -13
- package/src/presentation/activity-presentation.d.ts +9 -1
- package/src/presentation/activity-presentation.js +108 -25
- package/src/presentation/capabilities-presentation.d.ts +2 -0
- package/src/presentation/capabilities-presentation.js +3 -0
- package/src/presentation/column-presentation.d.ts +6 -0
- package/src/presentation/column-presentation.js +10 -0
- package/src/presentation/comment-presentation.d.ts +15 -0
- package/src/presentation/comment-presentation.js +29 -0
- package/src/presentation/description-presentation.d.ts +17 -0
- package/src/presentation/description-presentation.js +26 -4
- package/src/presentation/label-presentation.d.ts +8 -0
- package/src/presentation/label-presentation.js +28 -0
- package/src/presentation/project-presentation.d.ts +7 -0
- package/src/presentation/project-presentation.js +19 -0
- package/src/presentation/relation-presentation.d.ts +7 -0
- package/src/presentation/relation-presentation.js +73 -0
- package/src/presentation/task-presentation.d.ts +3 -3
- package/src/presentation/task-presentation.js +22 -18
- package/src/project.d.ts +14 -5
- package/src/project.js +18 -6
- package/src/result-schemas.d.ts +230 -23
- package/src/result-schemas.js +62 -3
- package/src/results.d.ts +34 -17
- package/src/results.js +19 -0
- package/src/routes/activity-router.d.ts +34 -1
- package/src/routes/activity-router.js +104 -31
- package/src/routes/aliases.d.ts +2 -0
- package/src/routes/aliases.js +11 -0
- package/src/routes/capabilities-router.js +9 -3
- package/src/routes/comment-router.d.ts +41 -18
- package/src/routes/comment-router.js +65 -48
- package/src/routes/label-router.d.ts +57 -7
- package/src/routes/label-router.js +84 -39
- package/src/routes/project-router.d.ts +34 -12
- package/src/routes/project-router.js +59 -55
- package/src/routes/relation-router.d.ts +6 -6
- package/src/routes/relation-router.js +52 -69
- package/src/routes/restore-router.js +1 -1
- package/src/routes/router.d.ts +1 -1
- package/src/routes/router.js +38 -9
- package/src/routes/routes.d.ts +253 -45
- package/src/routes/routes.js +4 -0
- package/src/routes/task-router.d.ts +107 -26
- package/src/routes/task-router.js +151 -143
- package/src/routes/whoami-router.d.ts +21 -0
- package/src/routes/whoami-router.js +31 -0
- package/src/text-edit.d.ts +13 -9
- package/src/text-edit.js +23 -18
- package/src/text-input.d.ts +47 -0
- package/src/text-input.js +187 -0
- package/src/types.d.ts +32 -9
- package/src/types.js +9 -1
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { comment } from "@zinn-dev/core";
|
|
4
|
-
import { generateCommandUsage, taskKeyPositional } from "../input.js";
|
|
5
|
-
import { confirmationDescription, confirmAction, dashValueHelp, output,
|
|
4
|
+
import { generateCommandUsage, getOptionInputs, taskKeyPositional, violatesConstraint, } from "../input.js";
|
|
5
|
+
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit, renameFlag, validatePositionals, validateUniqueOptions, } from "../lib.js";
|
|
6
6
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
7
|
+
import { resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
7
8
|
import { currentActor } from "../actor.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return comment.getAll(taskKey).map(presentComment);
|
|
20
|
-
}
|
|
21
|
-
function commentRow(commentMatch, options) {
|
|
22
|
-
const createdAtCells = options.showsCreatedAt
|
|
23
|
-
? [{ text: formatLocalTime(commentMatch.created_at), style: "dim" }]
|
|
24
|
-
: [];
|
|
25
|
-
return [{ text: commentMatch.key }, ...createdAtCells, { text: commentMatch.text }];
|
|
26
|
-
}
|
|
27
|
-
export function formatComment(commentMatch) {
|
|
28
|
-
return formatRows([commentRow(commentMatch, { showsCreatedAt: false })], {
|
|
29
|
-
indentsContinuationLines: true,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
export function formatComments(comments) {
|
|
33
|
-
return formatRows(comments.map((commentMatch) => commentRow(commentMatch, { showsCreatedAt: true })), { indentsContinuationLines: true });
|
|
9
|
+
import { formatCommentList, presentComment, presentComments, } from "../presentation/comment-presentation.js";
|
|
10
|
+
const commentTextConstraint = {
|
|
11
|
+
kind: "atLeastOne",
|
|
12
|
+
members: ["option:text", "option:text-file"],
|
|
13
|
+
};
|
|
14
|
+
function requireCommentText(values) {
|
|
15
|
+
if (violatesConstraint(commentTextConstraint, getOptionInputs(values))) {
|
|
16
|
+
quit("Comment text must be specified with --text or --text-file", undefined, {
|
|
17
|
+
argument: "--text",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
34
20
|
}
|
|
35
|
-
function parseTextArgs(args) {
|
|
21
|
+
async function parseTextArgs(args) {
|
|
36
22
|
const { values, positionals, tokens } = parseArgs({
|
|
37
23
|
args,
|
|
38
24
|
options: commentInputs.create.options,
|
|
@@ -42,10 +28,11 @@ function parseTextArgs(args) {
|
|
|
42
28
|
});
|
|
43
29
|
validateUniqueOptions(tokens, commentInputs.create.options);
|
|
44
30
|
validatePositionals(positionals, commentInputs.create.forms[0]);
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
requireCommentText(values);
|
|
32
|
+
const text = await resolveTextInput(values.text, values["text-file"], "--text");
|
|
33
|
+
return { key: positionals[0], text: text };
|
|
47
34
|
}
|
|
48
|
-
function parseCommentEditArgs(args) {
|
|
35
|
+
async function parseCommentEditArgs(args) {
|
|
49
36
|
const { values, positionals, tokens } = parseArgs({
|
|
50
37
|
args,
|
|
51
38
|
options: commentInputs.edit.options,
|
|
@@ -55,20 +42,24 @@ function parseCommentEditArgs(args) {
|
|
|
55
42
|
});
|
|
56
43
|
validateUniqueOptions(tokens, commentInputs.edit.options);
|
|
57
44
|
validatePositionals(positionals, commentInputs.edit.forms[0]);
|
|
58
|
-
const text = resolveTextEdit(values
|
|
59
|
-
|
|
45
|
+
const text = await resolveTextEdit(values, "--text");
|
|
46
|
+
// Without a text source nothing was read, so this usage error still comes before any input
|
|
47
|
+
requireCommentText(values);
|
|
60
48
|
return { key: positionals[0], text: text };
|
|
61
49
|
}
|
|
62
50
|
const commentInputs = {
|
|
63
51
|
create: {
|
|
64
|
-
options: {
|
|
52
|
+
options: {
|
|
53
|
+
text: { type: "string", value: { kind: "text", name: "text" } },
|
|
54
|
+
"text-file": textFileOption,
|
|
55
|
+
},
|
|
65
56
|
forms: [
|
|
66
57
|
{
|
|
67
58
|
id: "default",
|
|
68
59
|
positionals: [taskKeyPositional],
|
|
69
60
|
},
|
|
70
61
|
],
|
|
71
|
-
constraints: [],
|
|
62
|
+
constraints: [textSourceConstraint("--text"), commentTextConstraint],
|
|
72
63
|
},
|
|
73
64
|
list: {
|
|
74
65
|
options: {},
|
|
@@ -92,7 +83,8 @@ const commentInputs = {
|
|
|
92
83
|
},
|
|
93
84
|
edit: {
|
|
94
85
|
options: {
|
|
95
|
-
text: { type: "string",
|
|
86
|
+
text: { type: "string", value: { kind: "text", name: "text" } },
|
|
87
|
+
"text-file": textFileOption,
|
|
96
88
|
...textEditOptions,
|
|
97
89
|
},
|
|
98
90
|
forms: [
|
|
@@ -101,7 +93,11 @@ const commentInputs = {
|
|
|
101
93
|
positionals: [{ name: "comment-key", min: 1, max: 1, value: { kind: "comment-key" } }],
|
|
102
94
|
},
|
|
103
95
|
],
|
|
104
|
-
constraints: [
|
|
96
|
+
constraints: [
|
|
97
|
+
textSourceConstraint("--text"),
|
|
98
|
+
...textEditConstraints("--text"),
|
|
99
|
+
commentTextConstraint,
|
|
100
|
+
],
|
|
105
101
|
notes: [textEditHelp("--text")],
|
|
106
102
|
},
|
|
107
103
|
delete: {
|
|
@@ -122,15 +118,25 @@ export const commentRouter = {
|
|
|
122
118
|
confirmation: { kind: "none" },
|
|
123
119
|
input: commentInputs.create,
|
|
124
120
|
results: [jsonResult("Comment")],
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
guessedFlags: {
|
|
122
|
+
"--body": (args) => [
|
|
123
|
+
"task",
|
|
124
|
+
"comment",
|
|
125
|
+
"create",
|
|
126
|
+
...renameFlag(args, commentInputs.create.options, "body", "text"),
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
run: async (args) => {
|
|
130
|
+
const props = await parseTextArgs(args);
|
|
127
131
|
const created = comment.create({ taskKey: props.key, text: props.text }, currentActor());
|
|
128
|
-
output(presentComment(created),
|
|
132
|
+
output(presentComment(created), (entry) => formatCommentList([entry], { showsCreatedAt: false, showsTextPreview: true }));
|
|
129
133
|
},
|
|
130
134
|
help: `${generateCommandUsage("task comment create", commentInputs.create)}
|
|
131
135
|
|
|
132
136
|
Add a comment to a task. Comment text cannot be blank.
|
|
137
|
+
${textFileHelp("--text")}
|
|
133
138
|
Archived tasks can be commented on.
|
|
139
|
+
The printed result is a preview. 'task comment view' shows the full text. --json keeps the full text.
|
|
134
140
|
|
|
135
141
|
${dashValueHelp("--text")}
|
|
136
142
|
|
|
@@ -150,7 +156,7 @@ Example: zinn task comment create MDR-1 --text 'Ready for review'`,
|
|
|
150
156
|
strict: true,
|
|
151
157
|
});
|
|
152
158
|
validatePositionals(positionals, commentInputs.list.forms[0]);
|
|
153
|
-
output(presentComments(positionals[0]),
|
|
159
|
+
output(presentComments(positionals[0]), formatCommentList);
|
|
154
160
|
},
|
|
155
161
|
help: `${generateCommandUsage("task comment list", commentInputs.list)}
|
|
156
162
|
|
|
@@ -172,13 +178,13 @@ Example: zinn task comment list MDR-1`,
|
|
|
172
178
|
strict: true,
|
|
173
179
|
});
|
|
174
180
|
validatePositionals(positionals, commentInputs.view.forms[0]);
|
|
175
|
-
output(presentComment(comment.getByKey(positionals[0])),
|
|
181
|
+
output(presentComment(comment.getByKey(positionals[0])), (entry) => formatCommentList([entry], { showsCreatedAt: false }));
|
|
176
182
|
},
|
|
177
183
|
help: `${generateCommandUsage("task comment view", commentInputs.view)}
|
|
178
184
|
|
|
179
185
|
Show a comment's current text in full, keeping its line breaks.
|
|
180
186
|
Comments on archived tasks can be viewed.
|
|
181
|
-
With --json, return one object with key, text, created_at and updated_at.
|
|
187
|
+
With --json, return one object with id, key, task_id, text, created_at and updated_at.
|
|
182
188
|
|
|
183
189
|
Example: zinn task comment view 'MDR-1#1'`,
|
|
184
190
|
},
|
|
@@ -187,15 +193,26 @@ Example: zinn task comment view 'MDR-1#1'`,
|
|
|
187
193
|
effects: { domain: "update", storage: "normal-open" },
|
|
188
194
|
confirmation: { kind: "none" },
|
|
189
195
|
input: commentInputs.edit,
|
|
190
|
-
results: [jsonResult("
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
results: [jsonResult("CommentChange")],
|
|
197
|
+
guessedFlags: {
|
|
198
|
+
"--body": (args) => [
|
|
199
|
+
"task",
|
|
200
|
+
"comment",
|
|
201
|
+
"edit",
|
|
202
|
+
...renameFlag(args, commentInputs.edit.options, "body", "text"),
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
run: async (args) => {
|
|
206
|
+
const props = await parseCommentEditArgs(args);
|
|
193
207
|
const edited = comment.edit({ commentKey: props.key, text: props.text }, currentActor());
|
|
194
|
-
|
|
208
|
+
outputChanges([edited], (change) => presentComment(change.comment), (entries) => formatCommentList(entries, { showsCreatedAt: false, showsTextPreview: true }), (entry) => `Comment ${entry.key} was unchanged`);
|
|
195
209
|
},
|
|
196
210
|
help: `${generateCommandUsage("task comment edit", commentInputs.edit)}
|
|
197
211
|
|
|
198
212
|
Replace a comment's text. Comment text cannot be blank.
|
|
213
|
+
With --json, changed is false when the text already matches.
|
|
214
|
+
${textFileHelp("--text")}
|
|
215
|
+
The printed result is a preview. 'task comment view' shows the full text. --json keeps the full text.
|
|
199
216
|
|
|
200
217
|
${textEditHelp("--text")}
|
|
201
218
|
|
|
@@ -17,6 +17,14 @@ export declare const labelRouter: {
|
|
|
17
17
|
readonly name: "text";
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
readonly "description-file": {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly value: {
|
|
23
|
+
readonly kind: "path";
|
|
24
|
+
readonly name: "path";
|
|
25
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
20
28
|
readonly color: {
|
|
21
29
|
readonly type: "string";
|
|
22
30
|
readonly value: {
|
|
@@ -37,10 +45,13 @@ export declare const labelRouter: {
|
|
|
37
45
|
};
|
|
38
46
|
}];
|
|
39
47
|
}];
|
|
40
|
-
readonly constraints: readonly [
|
|
48
|
+
readonly constraints: readonly [{
|
|
49
|
+
readonly kind: "exclusive";
|
|
50
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
51
|
+
}];
|
|
41
52
|
};
|
|
42
53
|
results: import("../results.js").CommandResult[];
|
|
43
|
-
run: (args: string[]) => void
|
|
54
|
+
run: (args: string[]) => Promise<void>;
|
|
44
55
|
help: string;
|
|
45
56
|
};
|
|
46
57
|
list: {
|
|
@@ -64,6 +75,34 @@ export declare const labelRouter: {
|
|
|
64
75
|
run: (args: string[]) => void;
|
|
65
76
|
help: string;
|
|
66
77
|
};
|
|
78
|
+
view: {
|
|
79
|
+
summary: string;
|
|
80
|
+
effects: {
|
|
81
|
+
domain: "read";
|
|
82
|
+
storage: "normal-open";
|
|
83
|
+
};
|
|
84
|
+
confirmation: {
|
|
85
|
+
kind: "none";
|
|
86
|
+
};
|
|
87
|
+
input: {
|
|
88
|
+
readonly options: {};
|
|
89
|
+
readonly forms: readonly [{
|
|
90
|
+
readonly id: "default";
|
|
91
|
+
readonly positionals: readonly [{
|
|
92
|
+
readonly name: "name";
|
|
93
|
+
readonly min: 1;
|
|
94
|
+
readonly max: 1;
|
|
95
|
+
readonly value: {
|
|
96
|
+
readonly kind: "label-name";
|
|
97
|
+
};
|
|
98
|
+
}];
|
|
99
|
+
}];
|
|
100
|
+
readonly constraints: readonly [];
|
|
101
|
+
};
|
|
102
|
+
results: import("../results.js").CommandResult[];
|
|
103
|
+
run: (args: string[]) => void;
|
|
104
|
+
help: string;
|
|
105
|
+
};
|
|
67
106
|
edit: {
|
|
68
107
|
summary: string;
|
|
69
108
|
effects: {
|
|
@@ -110,6 +149,14 @@ export declare const labelRouter: {
|
|
|
110
149
|
readonly name: "text";
|
|
111
150
|
};
|
|
112
151
|
};
|
|
152
|
+
readonly "description-file": {
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
readonly value: {
|
|
155
|
+
readonly kind: "path";
|
|
156
|
+
readonly name: "path";
|
|
157
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
158
|
+
};
|
|
159
|
+
};
|
|
113
160
|
};
|
|
114
161
|
readonly forms: readonly [{
|
|
115
162
|
readonly id: "default";
|
|
@@ -123,16 +170,19 @@ export declare const labelRouter: {
|
|
|
123
170
|
}];
|
|
124
171
|
}];
|
|
125
172
|
readonly constraints: readonly [{
|
|
173
|
+
readonly kind: "exclusive";
|
|
174
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
175
|
+
}, {
|
|
126
176
|
readonly kind: "exclusive";
|
|
127
177
|
readonly members: readonly ["option:append", "option:replacing"];
|
|
128
178
|
}, {
|
|
129
|
-
readonly kind: "
|
|
179
|
+
readonly kind: "requiresAny";
|
|
130
180
|
readonly input: "option:append";
|
|
131
|
-
readonly
|
|
181
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
132
182
|
}, {
|
|
133
|
-
readonly kind: "
|
|
183
|
+
readonly kind: "requiresAny";
|
|
134
184
|
readonly input: "option:replacing";
|
|
135
|
-
readonly
|
|
185
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
136
186
|
}, {
|
|
137
187
|
readonly kind: "requires";
|
|
138
188
|
readonly input: "option:all";
|
|
@@ -144,7 +194,7 @@ export declare const labelRouter: {
|
|
|
144
194
|
readonly notes: readonly [string];
|
|
145
195
|
};
|
|
146
196
|
results: import("../results.js").CommandResult[];
|
|
147
|
-
run: (args: string[]) => void
|
|
197
|
+
run: (args: string[]) => Promise<void>;
|
|
148
198
|
help: string;
|
|
149
199
|
};
|
|
150
200
|
delete: {
|
|
@@ -3,31 +3,11 @@ import { parseArgs } from "node:util";
|
|
|
3
3
|
import { label, labelColorSchema, labelCreateSchema, labelDeleteSchema, labelEditSchema, } from "@zinn-dev/core";
|
|
4
4
|
import { CliError } from "../errors.js";
|
|
5
5
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
6
|
-
import { confirmationDescription, confirmAction, dashValueHelp, output, validatePositionals, validateUniqueOptions, } from "../lib.js";
|
|
6
|
+
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, validatePositionals, validateUniqueOptions, } from "../lib.js";
|
|
7
7
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
8
|
+
import { checkFieldsBeforeText, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
8
9
|
import { currentActor } from "../actor.js";
|
|
9
|
-
import {
|
|
10
|
-
import { formatRows } from "../presentation/row-layout.js";
|
|
11
|
-
function presentLabel(labelMatch) {
|
|
12
|
-
return { name: labelMatch.name, color: labelMatch.color, description: labelMatch.description };
|
|
13
|
-
}
|
|
14
|
-
function formatLabel(presented) {
|
|
15
|
-
return formatLabelList([presented]);
|
|
16
|
-
}
|
|
17
|
-
function formatLabelList(presentedLabels) {
|
|
18
|
-
return formatRows(presentedLabels.map((presented) => {
|
|
19
|
-
const descriptionCells = presented.description == null ? [] : [{ text: presented.description }];
|
|
20
|
-
/**
|
|
21
|
-
* The colored name shows the color, and if the environment
|
|
22
|
-
* does not support color, it is explicitly printed instead
|
|
23
|
-
*/
|
|
24
|
-
if (isColorEnabled()) {
|
|
25
|
-
const style = labelColorSchema.options.find((color) => color === presented.color);
|
|
26
|
-
return [{ text: presented.name, style }, ...descriptionCells];
|
|
27
|
-
}
|
|
28
|
-
return [{ text: presented.name }, { text: presented.color }, ...descriptionCells];
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
10
|
+
import { formatLabelList, presentLabel } from "../presentation/label-presentation.js";
|
|
31
11
|
const colorOption = {
|
|
32
12
|
type: "string",
|
|
33
13
|
value: {
|
|
@@ -40,18 +20,30 @@ const labelInputs = {
|
|
|
40
20
|
create: {
|
|
41
21
|
options: {
|
|
42
22
|
description: { type: "string", value: { kind: "text", name: "text" } },
|
|
23
|
+
"description-file": textFileOption,
|
|
43
24
|
color: colorOption,
|
|
44
25
|
},
|
|
45
26
|
forms: [
|
|
46
27
|
{ id: "default", positionals: [{ name: "name", min: 1, max: 1, value: { kind: "name" } }] },
|
|
47
28
|
],
|
|
48
|
-
constraints: [],
|
|
29
|
+
constraints: [textSourceConstraint("--description")],
|
|
49
30
|
},
|
|
50
31
|
list: noInput,
|
|
32
|
+
view: {
|
|
33
|
+
options: {},
|
|
34
|
+
forms: [
|
|
35
|
+
{
|
|
36
|
+
id: "default",
|
|
37
|
+
positionals: [{ name: "name", min: 1, max: 1, value: { kind: "label-name" } }],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
constraints: [],
|
|
41
|
+
},
|
|
51
42
|
edit: {
|
|
52
43
|
options: {
|
|
53
44
|
name: { type: "string", value: { kind: "text", name: "text" } },
|
|
54
45
|
description: { type: "string", value: { kind: "text", name: "text" } },
|
|
46
|
+
"description-file": textFileOption,
|
|
55
47
|
...textEditOptions,
|
|
56
48
|
color: colorOption,
|
|
57
49
|
},
|
|
@@ -59,12 +51,16 @@ const labelInputs = {
|
|
|
59
51
|
{ id: "default", positionals: [{ name: "name", min: 1, max: 1, value: { kind: "name" } }] },
|
|
60
52
|
],
|
|
61
53
|
constraints: [
|
|
54
|
+
textSourceConstraint("--description"),
|
|
62
55
|
...textEditConstraints("--description"),
|
|
63
56
|
{
|
|
64
57
|
kind: "atLeastOne",
|
|
58
|
+
// A description can also come from --description-file
|
|
65
59
|
members: Object.keys(labelEditSchema.shape)
|
|
66
60
|
.filter((name) => name !== "labelName")
|
|
67
|
-
.
|
|
61
|
+
.flatMap((name) => name === "description"
|
|
62
|
+
? textSourceConstraint("--description").members
|
|
63
|
+
: [`option:${name}`]),
|
|
68
64
|
},
|
|
69
65
|
],
|
|
70
66
|
notes: [textEditHelp("--description")],
|
|
@@ -84,7 +80,7 @@ export const labelRouter = {
|
|
|
84
80
|
confirmation: { kind: "none" },
|
|
85
81
|
input: labelInputs.create,
|
|
86
82
|
results: [jsonResult("Label")],
|
|
87
|
-
run: (args) => {
|
|
83
|
+
run: async (args) => {
|
|
88
84
|
const { values, positionals, tokens } = parseArgs({
|
|
89
85
|
args,
|
|
90
86
|
options: labelInputs.create.options,
|
|
@@ -94,15 +90,23 @@ export const labelRouter = {
|
|
|
94
90
|
});
|
|
95
91
|
validateUniqueOptions(tokens, labelInputs.create.options);
|
|
96
92
|
validatePositionals(positionals, labelInputs.create.forms[0]);
|
|
97
|
-
|
|
93
|
+
checkFieldsBeforeText(labelCreateSchema, { name: positionals[0], color: values.color });
|
|
94
|
+
const description = await resolveTextInput(values.description, values["description-file"], "--description");
|
|
95
|
+
const input = labelCreateSchema.parse({
|
|
96
|
+
name: positionals[0],
|
|
97
|
+
description,
|
|
98
|
+
color: values.color,
|
|
99
|
+
});
|
|
98
100
|
const created = label.create(input, currentActor());
|
|
99
|
-
output(presentLabel(created),
|
|
101
|
+
output(presentLabel(created), (entry) => formatLabelList([entry], { showsDescriptionPreview: true }));
|
|
100
102
|
},
|
|
101
103
|
help: `${generateCommandUsage("label create", labelInputs.create)}
|
|
102
104
|
|
|
103
105
|
Create a global label. Names preserve casing, but uniqueness is case-insensitive.
|
|
104
106
|
Names are trimmed and cannot be blank or contain line breaks or control characters.
|
|
105
107
|
Description is optional.
|
|
108
|
+
${textFileHelp("--description")}
|
|
109
|
+
The printed result is a preview. 'label view' and --json show the full text.
|
|
106
110
|
|
|
107
111
|
Color defaults to white.
|
|
108
112
|
Valid colors: ${labelInputs.create.options.color.value.choices.join(", ")}.
|
|
@@ -125,19 +129,53 @@ Example: zinn label create bug --description 'Unexpected behavior' --color red`,
|
|
|
125
129
|
allowPositionals: true,
|
|
126
130
|
});
|
|
127
131
|
validatePositionals(positionals, labelInputs.list.forms[0]);
|
|
128
|
-
output(label.getAll().map(presentLabel), formatLabelList);
|
|
132
|
+
output(label.getAll().map(presentLabel), (entries) => formatLabelList(entries, { showsDescriptionPreview: true }));
|
|
129
133
|
},
|
|
130
134
|
help: `${generateCommandUsage("label list", labelInputs.list)}
|
|
131
135
|
|
|
132
|
-
List all global label definitions
|
|
136
|
+
List all global label definitions.
|
|
137
|
+
Descriptions are previews.
|
|
138
|
+
Use label view <name> for the full description. --json keeps the full text.`,
|
|
139
|
+
},
|
|
140
|
+
view: {
|
|
141
|
+
summary: "Show a global label with its full description.",
|
|
142
|
+
effects: { domain: "read", storage: "normal-open" },
|
|
143
|
+
confirmation: { kind: "none" },
|
|
144
|
+
input: labelInputs.view,
|
|
145
|
+
results: [jsonResult("Label")],
|
|
146
|
+
run: (args) => {
|
|
147
|
+
const { positionals } = parseArgs({
|
|
148
|
+
args,
|
|
149
|
+
options: labelInputs.view.options,
|
|
150
|
+
strict: true,
|
|
151
|
+
allowPositionals: true,
|
|
152
|
+
});
|
|
153
|
+
validatePositionals(positionals, labelInputs.view.forms[0]);
|
|
154
|
+
const props = labelDeleteSchema.parse({ name: positionals[0] });
|
|
155
|
+
const labelMatch = label.getByName(props.name);
|
|
156
|
+
if (labelMatch == null) {
|
|
157
|
+
throw new CliError(`A label with name "${props.name}" does not exist`, "not_found", {
|
|
158
|
+
entity: "label",
|
|
159
|
+
key: props.name,
|
|
160
|
+
source: "explicit",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
output(presentLabel(labelMatch), (entry) => formatLabelList([entry]));
|
|
164
|
+
},
|
|
165
|
+
help: `${generateCommandUsage("label view", labelInputs.view)}
|
|
166
|
+
|
|
167
|
+
Show a global label with its full description, preserving line breaks and whitespace.
|
|
168
|
+
Label names are matched case-insensitively.
|
|
169
|
+
|
|
170
|
+
Example: zinn label view bug`,
|
|
133
171
|
},
|
|
134
172
|
edit: {
|
|
135
173
|
summary: "Change specified fields.",
|
|
136
174
|
effects: { domain: "update", storage: "normal-open" },
|
|
137
175
|
confirmation: { kind: "none" },
|
|
138
176
|
input: labelInputs.edit,
|
|
139
|
-
results: [jsonResult("
|
|
140
|
-
run: (args) => {
|
|
177
|
+
results: [jsonResult("LabelChange")],
|
|
178
|
+
run: async (args) => {
|
|
141
179
|
const { values, positionals, tokens } = parseArgs({
|
|
142
180
|
args,
|
|
143
181
|
options: labelInputs.edit.options,
|
|
@@ -147,26 +185,33 @@ List all global label definitions.`,
|
|
|
147
185
|
});
|
|
148
186
|
validateUniqueOptions(tokens, labelInputs.edit.options);
|
|
149
187
|
validatePositionals(positionals, labelInputs.edit.forms[0]);
|
|
188
|
+
checkFieldsBeforeText(labelEditSchema, {
|
|
189
|
+
labelName: positionals[0],
|
|
190
|
+
name: values.name,
|
|
191
|
+
color: values.color,
|
|
192
|
+
});
|
|
193
|
+
const description = await resolveTextEdit(values, "--description");
|
|
150
194
|
const input = labelEditSchema.parse({
|
|
151
195
|
labelName: positionals[0],
|
|
152
196
|
name: values.name,
|
|
153
|
-
description
|
|
197
|
+
description,
|
|
154
198
|
color: values.color,
|
|
155
199
|
});
|
|
156
200
|
const edited = label.edit(input, currentActor());
|
|
157
|
-
|
|
201
|
+
outputChanges([edited], (change) => presentLabel(change.label), (entries) => formatLabelList(entries, { showsDescriptionPreview: true }), (entry) => `Label "${entry.name}" was unchanged`);
|
|
158
202
|
},
|
|
159
203
|
help: `${generateCommandUsage("label edit", labelInputs.edit)}
|
|
160
204
|
|
|
161
205
|
Change specified fields.
|
|
206
|
+
With --json, changed is false when all supplied values already match.
|
|
162
207
|
Provide at least one edit flag. Use --description '' to clear the description.
|
|
208
|
+
${textFileHelp("--description")}
|
|
209
|
+
Description echoes use a preview; label view and --json keep the full text.
|
|
163
210
|
Valid colors: ${labelInputs.edit.options.color.value.choices.join(", ")}.
|
|
164
211
|
|
|
165
212
|
${textEditHelp("--description")}
|
|
166
213
|
|
|
167
|
-
|
|
168
|
-
Names are trimmed. Changing only the casing is allowed.
|
|
169
|
-
Editing does not affect task attachments or task timestamps.
|
|
214
|
+
Label names match without case sensitivity.
|
|
170
215
|
|
|
171
216
|
${dashValueHelp("--description")}
|
|
172
217
|
|
|
@@ -201,11 +246,11 @@ Examples:
|
|
|
201
246
|
}
|
|
202
247
|
const canDelete = await confirmAction(`Are you sure you want to delete label "${labelMatch.name}" and remove it from all tasks?`, values.yes === true);
|
|
203
248
|
if (!canDelete) {
|
|
204
|
-
output(presentLabel(labelMatch), (
|
|
249
|
+
output(presentLabel(labelMatch), (entry) => `Deletion cancelled for ${formatLabelList([entry], { showsDescriptionPreview: true })}`);
|
|
205
250
|
return;
|
|
206
251
|
}
|
|
207
252
|
const deleted = label.delete(props, currentActor());
|
|
208
|
-
output(presentLabel(deleted), (
|
|
253
|
+
output(presentLabel(deleted), (entry) => `Deleted ${formatLabelList([entry], { showsDescriptionPreview: true })}`);
|
|
209
254
|
},
|
|
210
255
|
help: `${generateCommandUsage("label delete", labelInputs.delete)}
|
|
211
256
|
|
|
@@ -24,6 +24,14 @@ export declare const projectRouter: {
|
|
|
24
24
|
readonly name: "text";
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
readonly "description-file": {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly value: {
|
|
30
|
+
readonly kind: "path";
|
|
31
|
+
readonly name: "path";
|
|
32
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
27
35
|
};
|
|
28
36
|
readonly forms: readonly [{
|
|
29
37
|
readonly id: "default";
|
|
@@ -36,10 +44,13 @@ export declare const projectRouter: {
|
|
|
36
44
|
};
|
|
37
45
|
}];
|
|
38
46
|
}];
|
|
39
|
-
readonly constraints: readonly [
|
|
47
|
+
readonly constraints: readonly [{
|
|
48
|
+
readonly kind: "exclusive";
|
|
49
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
50
|
+
}];
|
|
40
51
|
};
|
|
41
52
|
results: import("../results.js").CommandResult[];
|
|
42
|
-
run: (args: Array<string>) => void
|
|
53
|
+
run: (args: Array<string>) => Promise<void>;
|
|
43
54
|
help: string;
|
|
44
55
|
};
|
|
45
56
|
list: {
|
|
@@ -86,7 +97,7 @@ export declare const projectRouter: {
|
|
|
86
97
|
}];
|
|
87
98
|
}];
|
|
88
99
|
readonly constraints: readonly [];
|
|
89
|
-
readonly notes: readonly ["
|
|
100
|
+
readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
|
|
90
101
|
};
|
|
91
102
|
results: import("../results.js").CommandResult[];
|
|
92
103
|
run: (args: Array<string>) => void;
|
|
@@ -130,6 +141,14 @@ export declare const projectRouter: {
|
|
|
130
141
|
readonly name: "text";
|
|
131
142
|
};
|
|
132
143
|
};
|
|
144
|
+
readonly "description-file": {
|
|
145
|
+
readonly type: "string";
|
|
146
|
+
readonly value: {
|
|
147
|
+
readonly kind: "path";
|
|
148
|
+
readonly name: "path";
|
|
149
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
133
152
|
};
|
|
134
153
|
readonly forms: readonly [{
|
|
135
154
|
readonly id: "default";
|
|
@@ -143,28 +162,31 @@ export declare const projectRouter: {
|
|
|
143
162
|
}];
|
|
144
163
|
}];
|
|
145
164
|
readonly constraints: readonly [{
|
|
165
|
+
readonly kind: "exclusive";
|
|
166
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
167
|
+
}, {
|
|
146
168
|
readonly kind: "exclusive";
|
|
147
169
|
readonly members: readonly ["option:append", "option:replacing"];
|
|
148
170
|
}, {
|
|
149
|
-
readonly kind: "
|
|
171
|
+
readonly kind: "requiresAny";
|
|
150
172
|
readonly input: "option:append";
|
|
151
|
-
readonly
|
|
173
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
152
174
|
}, {
|
|
153
|
-
readonly kind: "
|
|
175
|
+
readonly kind: "requiresAny";
|
|
154
176
|
readonly input: "option:replacing";
|
|
155
|
-
readonly
|
|
177
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
156
178
|
}, {
|
|
157
179
|
readonly kind: "requires";
|
|
158
180
|
readonly input: "option:all";
|
|
159
181
|
readonly requires: "option:replacing";
|
|
160
182
|
}, {
|
|
161
183
|
readonly kind: "atLeastOne";
|
|
162
|
-
readonly members: readonly ["option:name", "option:description"];
|
|
184
|
+
readonly members: readonly ["option:name", "option:description", "option:description-file"];
|
|
163
185
|
}];
|
|
164
|
-
readonly notes: readonly ["
|
|
186
|
+
readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required.", string];
|
|
165
187
|
};
|
|
166
188
|
results: import("../results.js").CommandResult[];
|
|
167
|
-
run: (args: string[]) => void
|
|
189
|
+
run: (args: string[]) => Promise<void>;
|
|
168
190
|
help: string;
|
|
169
191
|
};
|
|
170
192
|
delete: {
|
|
@@ -195,7 +217,7 @@ export declare const projectRouter: {
|
|
|
195
217
|
}];
|
|
196
218
|
}];
|
|
197
219
|
readonly constraints: readonly [];
|
|
198
|
-
readonly notes: readonly ["
|
|
220
|
+
readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
|
|
199
221
|
};
|
|
200
222
|
results: import("../results.js").CommandResult[];
|
|
201
223
|
run: (args: Array<string>) => Promise<void>;
|
|
@@ -260,7 +282,7 @@ export declare const projectRouter: {
|
|
|
260
282
|
}];
|
|
261
283
|
}];
|
|
262
284
|
readonly constraints: readonly [];
|
|
263
|
-
readonly notes: readonly ["
|
|
285
|
+
readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
|
|
264
286
|
};
|
|
265
287
|
results: import("../results.js").CommandResult[];
|
|
266
288
|
run: (args: Array<string>) => void;
|