@zinn-dev/cli 0.20.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
@@ -140,7 +140,8 @@ zinn task comment list MDR-1
140
140
  ```
141
141
 
142
142
  Comments receive keys per task like `MDR-1#1`.
143
- `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.
144
145
 
145
146
  Edit or delete a comment using its key:
146
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "A kanban workflow in the terminal.",
5
5
  "license": "MIT",
6
6
  "bugs": {
@@ -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") {