@zinn-dev/cli 0.13.0 → 0.15.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 CHANGED
@@ -93,6 +93,8 @@ Label names are case-sensitive, and the whitespace from input is trimmed.
93
93
 
94
94
  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_.
95
95
 
96
+ `label create` and `label list` print each label name in its color. `--json` output shows the color as a value instead.
97
+
96
98
  Task creation and edits apply content and label changes together, or roll back together on failure.
97
99
  Note that label changes also update the task's modification timestamp. Archived tasks can also have their labels edited.
98
100
 
@@ -146,6 +148,7 @@ zinn task move MDR-1 "In Progress"
146
148
  ```
147
149
 
148
150
  A moved task appears at the bottom of its destination column. Moving it to its current column does nothing. Archived tasks must be unarchived before they can be moved.
151
+ Moving prints only the task's key and new column, such as `MDR-1 | In Progress`, while `--json` prints the full task details.
149
152
 
150
153
  Change a task's position within its current column:
151
154
 
@@ -207,4 +210,4 @@ zinn task edit MDR-1 --priority urgent
207
210
  zinn task edit MDR-1 --priority none
208
211
  ```
209
212
 
210
- Use `none` to clear priority. Omitting `--priority` on edits preserves it. Assigned priorities appear in task list and view output; board ordering remains unchanged.
213
+ Use `none` to clear priority. Omitting `--priority` on edits preserves it. Task lists show priority in a compact column after the board column: `-` for unassigned and `L`, `M`, `H`, or `U` for low, medium, high, or urgent. Task views show the full priority value. Priority does not affect board ordering.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.13.0",
3
+ "version": "0.15.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.11.0"
45
+ "@zinn-dev/core": "0.11.1"
46
46
  }
47
47
  }
@@ -1,7 +1,7 @@
1
1
  import type { Label } from "@zinn-dev/core";
2
2
  import type { RouteDef } from "../types";
3
3
 
4
- import { parseArgs } from "node:util";
4
+ import { parseArgs, styleText } from "node:util";
5
5
  import { label, labelCreateSchema, labelDeleteSchema } from "@zinn-dev/core";
6
6
 
7
7
  import {
@@ -19,7 +19,13 @@ function presentLabel(labelMatch: Label): PresentedLabel {
19
19
  }
20
20
 
21
21
  function formatLabel(presented: PresentedLabel) {
22
- return `${presented.name} | ${presented.color} | ${presented.description}`;
22
+ const coloredName = styleText(presented.color, presented.name);
23
+
24
+ if (presented.description.length === 0) {
25
+ return coloredName;
26
+ }
27
+
28
+ return `${coloredName} | ${presented.description}`;
23
29
  }
24
30
 
25
31
  export const labelRouter = {
@@ -14,7 +14,8 @@ function getNamespaceHelp(parsedRoutes: Array<ParsedRoute>, namespace: string) {
14
14
  const prefix = `${namespace} `;
15
15
  const commands = parsedRoutes
16
16
  .map((route) => route.command)
17
- .filter((command) => command.startsWith(prefix));
17
+ .filter((command) => command.startsWith(prefix))
18
+ .map((command) => command.slice(prefix.length));
18
19
 
19
20
  if (commands.length === 0) {
20
21
  return null;
@@ -1,7 +1,7 @@
1
1
  import type { TaskPriority } from "@zinn-dev/core";
2
2
  import type { RouteDef } from "../types";
3
3
 
4
- import { parseArgs } from "node:util";
4
+ import { parseArgs, styleText } from "node:util";
5
5
  import { task, project, column } from "@zinn-dev/core";
6
6
 
7
7
  import {
@@ -38,6 +38,29 @@ type PresentedTask = {
38
38
  labels: Array<string>;
39
39
  };
40
40
 
41
+ function formatTaskPriorityMarker(priority: TaskPriority | null) {
42
+ if (priority == null) {
43
+ return "-";
44
+ }
45
+
46
+ return priority[0]!.toUpperCase();
47
+ }
48
+
49
+ function formatTaskColumn(columnName: string, width = columnName.length) {
50
+ const paddedColumnName = columnName.padEnd(width);
51
+
52
+ // TODO: Derive column colors from column roles once roles exist instead of relying on names.
53
+ if (columnName === "Backlog") {
54
+ return styleText("gray", paddedColumnName);
55
+ }
56
+
57
+ if (columnName === "Done") {
58
+ return styleText("green", paddedColumnName);
59
+ }
60
+
61
+ return paddedColumnName;
62
+ }
63
+
41
64
  function presentTask(taskMatch: ReturnType<typeof task.getByKey>): PresentedTask {
42
65
  return {
43
66
  key: taskMatch.key,
@@ -52,21 +75,29 @@ function presentTask(taskMatch: ReturnType<typeof task.getByKey>): PresentedTask
52
75
 
53
76
  // TODO: a CLI row formatter that accepts text columns and joins them with " | " would be useful
54
77
  // Reuse it across task list/view and other command output in a separate change.
55
- function formatTask(presented: PresentedTask, options: { showsStatus?: boolean } = {}) {
78
+ function formatTask(
79
+ presented: PresentedTask,
80
+ options: { showsStatus?: boolean } = {},
81
+ ) {
56
82
  const status = options.showsStatus ? ` | ${presented.status}` : "";
83
+ const column = formatTaskColumn(presented.column);
57
84
  const description = presented.description == null ? "" : ` | ${presented.description}`;
58
85
 
59
86
  const priority = presented.priority == null ? "" : ` | Priority: ${presented.priority}`;
60
87
  const labelText =
61
88
  presented.labels.length === 0 ? "" : ` | Labels: ${presented.labels.join(", ")}`;
62
89
 
63
- return `${presented.key}${status} | ${presented.column} | ${presented.title}${description}${priority}${labelText}`;
90
+ return `${presented.key}${status} | ${column} | ${presented.title}${description}${priority}${labelText}`;
64
91
  }
65
92
 
66
93
  function formatTaskWithStatus(presented: PresentedTask) {
67
94
  return formatTask(presented, { showsStatus: true });
68
95
  }
69
96
 
97
+ function formatTaskMove(presented: PresentedTask) {
98
+ return `${presented.key} | ${formatTaskColumn(presented.column)}`;
99
+ }
100
+
70
101
  export const taskRouter = {
71
102
  edit: {
72
103
  run: (args) => {
@@ -209,6 +240,11 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
209
240
  (prev, current) => Math.max(prev, current.key.length),
210
241
  0,
211
242
  );
243
+ const longestColumnNameLength = presentedTasks.reduce(
244
+ (previousLength, currentTask) =>
245
+ Math.max(previousLength, currentTask.column.length),
246
+ 0,
247
+ );
212
248
  const longestStatusLength = presentedTasks.reduce(
213
249
  (prev, current) => Math.max(prev, current.status.length),
214
250
  0,
@@ -220,8 +256,10 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
220
256
  const status = showsAll ? ` | ${t.status.padEnd(longestStatusLength)}` : "";
221
257
  const descriptionPreview = formatTaskDescriptionPreview(t.description);
222
258
  const description = t.description == null ? "" : ` | ${descriptionPreview}`;
223
- const priority = t.priority == null ? "" : ` | Priority: ${t.priority}`;
224
- return `${t.key.padEnd(longestKeyLength)}${status} | ${t.column} | ${t.title}${description}${priority}`;
259
+ const priority = formatTaskPriorityMarker(t.priority);
260
+ const column = formatTaskColumn(t.column, longestColumnNameLength);
261
+
262
+ return `${t.key.padEnd(longestKeyLength)}${status} | ${column} | ${priority} | ${t.title}${description}`;
225
263
  })
226
264
  .join("\n");
227
265
  });
@@ -230,6 +268,7 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
230
268
 
231
269
  List active tasks by default.
232
270
  Use --archived to list archived tasks or --all to list both.
271
+ Priority markers: - unassigned, L low, M medium, H high, U urgent.
233
272
 
234
273
  Example: zinn task list MDR --all`,
235
274
  },
@@ -246,9 +285,11 @@ Example: zinn task list MDR --all`,
246
285
 
247
286
  output(viewedTask, (t) => {
248
287
  const relations = formatRelations(t.relations);
288
+ const formattedTask = formatTask(t);
289
+
249
290
  return relations.length > 0
250
- ? `${formatTask(t)}\n\nRelations:\n${relations}`
251
- : formatTask(t);
291
+ ? `${formattedTask}\n\nRelations:\n${relations}`
292
+ : formattedTask;
252
293
  });
253
294
  },
254
295
  help: `Usage: zinn task view <task-key>
@@ -270,7 +311,7 @@ Example: zinn task view MDR-1`,
270
311
  }
271
312
 
272
313
  const movedTask = task.move({ taskKey, targetColumn });
273
- output(presentTask(movedTask), formatTask);
314
+ output(presentTask(movedTask), formatTaskMove);
274
315
  },
275
316
  help: `Usage: zinn task move <task-key> <target-column>
276
317
 
@@ -278,6 +319,8 @@ Move a task to another column in its project.
278
319
  Moving a task to a different column lists it last in that column,
279
320
  matching placement at the bottom of a visual kanban column.
280
321
 
322
+ Prints the task's key and new column.
323
+
281
324
  Giving a task's current column as the target will not do anything.
282
325
  Archived tasks must be unarchived before they can be moved.
283
326