@zinn-dev/cli 0.19.0 → 0.21.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
@@ -78,6 +78,7 @@ Labels are global and reusable in all the available projects.
78
78
  ```sh
79
79
  zinn label create urgent --color red --description "Needs attention soon"
80
80
  zinn label create review
81
+ zinn label edit review --name ready --color green
81
82
  zinn label list
82
83
  ```
83
84
 
@@ -98,6 +99,8 @@ Descriptions default to an empty string and the label colors default to white. A
98
99
 
99
100
  `label create` and `label list` print each label name in its color. `--json` output shows the color as a value instead.
100
101
 
102
+ `label edit` changes only the supplied name, color, or description. Renaming preserves every task attachment because attachments refer to the label's internal ID. Also, updating a label does not affect any tasks' timestamps that it is attached to.
103
+
101
104
  Task creation and edits apply content and label changes together, or roll back together on failure.
102
105
  Note that label changes also update the task's modification timestamp. Archived tasks can also have their labels edited.
103
106
 
@@ -137,7 +140,8 @@ zinn task comment list MDR-1
137
140
  ```
138
141
 
139
142
  Comments receive keys per task like `MDR-1#1`.
140
- `task view` includes the task's comments.
143
+ Comment lists show each comment's creation time in local time as `YYYY-MM-DD HH:mm ±HH:mm`.
144
+ `task view` includes the task's comments in the same format.
141
145
 
142
146
  Edit or delete a comment using its key:
143
147
 
package/index.ts CHANGED
@@ -44,6 +44,7 @@ Commands:
44
44
  task label add
45
45
  task label remove
46
46
  label create
47
+ label edit
47
48
  label list
48
49
  label delete
49
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.19.0",
3
+ "version": "0.21.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.13.0"
45
+ "@zinn-dev/core": "0.14.0"
46
46
  }
47
47
  }
@@ -28,14 +28,39 @@ export function presentComments(taskKey: string) {
28
28
  return comment.getAll(taskKey).map(presentComment);
29
29
  }
30
30
 
31
- export function formatComment(commentMatch: PresentedComment) {
32
- const continuationIndent = " ".repeat(`${commentMatch.key} | `.length);
31
+ function formatCommentCreatedAt(createdAt: number) {
32
+ const date = new Date(createdAt);
33
+ const offsetMinutes = -date.getTimezoneOffset();
34
+ const offsetSign = offsetMinutes >= 0 ? "+" : "-";
35
+ const absoluteOffsetMinutes = Math.abs(offsetMinutes);
36
+ const offsetHours = Math.floor(absoluteOffsetMinutes / 60);
37
+ const remainingOffsetMinutes = absoluteOffsetMinutes % 60;
38
+ const pad = (value: number) => String(value).padStart(2, "0");
39
+
40
+ return (
41
+ `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
42
+ `${pad(date.getHours())}:${pad(date.getMinutes())} ` +
43
+ `${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`
44
+ );
45
+ }
46
+
47
+ export function formatComment(
48
+ commentMatch: PresentedComment,
49
+ options: { showsCreatedAt?: boolean } = {},
50
+ ) {
51
+ const createdAt = options.showsCreatedAt
52
+ ? ` | ${formatCommentCreatedAt(commentMatch.created_at)}`
53
+ : "";
54
+ const prefix = `${commentMatch.key}${createdAt} | `;
55
+ const continuationIndent = " ".repeat(prefix.length);
33
56
  const text = commentMatch.text.split(/\r?\n/).join(`\n${continuationIndent}`);
34
- return `${commentMatch.key} | ${text}`;
57
+ return `${prefix}${text}`;
35
58
  }
36
59
 
37
60
  export function formatComments(comments: Array<PresentedComment>) {
38
- return comments.map(formatComment).join("\n");
61
+ return comments
62
+ .map((commentMatch) => formatComment(commentMatch, { showsCreatedAt: true }))
63
+ .join("\n");
39
64
  }
40
65
 
41
66
  function parseTextArgs(args: Array<string>, entityName: "task" | "comment") {
@@ -2,7 +2,7 @@ import type { Label } from "@zinn-dev/core";
2
2
  import type { RouteDef } from "../types";
3
3
 
4
4
  import { parseArgs, styleText } from "node:util";
5
- import { label, labelCreateSchema, labelDeleteSchema } from "@zinn-dev/core";
5
+ import { label, labelCreateSchema, labelDeleteSchema, labelEditSchema } from "@zinn-dev/core";
6
6
 
7
7
  import {
8
8
  confirmAction,
@@ -56,6 +56,38 @@ Description defaults to an empty string; color defaults to white.
56
56
  Colors: red, green, yellow, blue, magenta, cyan, white, gray.
57
57
 
58
58
  Example: zinn label create bug --description "Unexpected behavior" --color red`,
59
+ },
60
+ edit: {
61
+ run: (args) => {
62
+ const { values, positionals, tokens } = parseArgs({
63
+ args,
64
+ options: {
65
+ name: { type: "string" },
66
+ description: { type: "string" },
67
+ color: { type: "string" },
68
+ },
69
+ allowPositionals: true,
70
+ strict: true,
71
+ tokens: true,
72
+ });
73
+
74
+ validatePositionalCount(positionals, 1, "Exactly one label name is required");
75
+ validateUniqueOptions(tokens);
76
+
77
+ const input = labelEditSchema.parse({ labelName: positionals[0], ...values });
78
+ const edited = label.edit(input);
79
+
80
+ output(presentLabel(edited), formatLabel);
81
+ },
82
+ help: `Usage: zinn label edit <name> [--name <text>] [--description <text>] [--color <color>]
83
+
84
+ Change specified fields.
85
+ Provide at least one edit flag. Use --description "" for an empty description.
86
+
87
+ Names are case-sensitive, trimmed, and must remain unique.
88
+ Editing does not affect task attachments or task timestamps.
89
+
90
+ Example: zinn label edit bug --name defect --color yellow`,
59
91
  },
60
92
  list: {
61
93
  run: (args) => {