@zinn-dev/cli 0.34.0 → 0.35.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
@@ -13,15 +13,17 @@ Set `ZINN_DIR` to use another Zinn directory and keep using the same value for c
13
13
 
14
14
  ## Start a project
15
15
 
16
- Create a project with a key or optionally provide a name:
16
+ Create a project with a key and optionally provide a name and description:
17
17
 
18
18
  ```sh
19
- zinn project create MDR --name "Macrodata Refinement"
19
+ zinn project create MDR --name "Macrodata Refinement" --description "Refine macrodata"
20
20
  ```
21
21
 
22
22
  Project keys are stored in **uppercase**. You can create a project without a project name, like `zinn project create MDR`, which will just default to having the key as the project name too.
23
23
  Intetionally empty or whitespace project names are rejected.
24
24
 
25
+ Project descriptions are optional and may contain multiple lines. If a description is not provided, it is stored as `null`. Also, if you want to _empty_ an existing description, you can do so with `project edit --description ""`, which stores an empty string. Project list, view and mutation text show _truncated_ inline description previews. Project JSON includes `description`, including null and empty strings.
26
+
25
27
  Each project starts with _Backlog_, _TODO_, _In Progress_, _Review_, and _Done_ columns.
26
28
 
27
29
  You can list projects or inspect a project's columns with:
@@ -34,14 +36,16 @@ zinn project column list MDR
34
36
 
35
37
  `project view` prints the project and its unarchived tasks. It's the same list as you would get with `zinn task list <project-key>`.
36
38
 
37
- Rename a project:
39
+ Edit a project:
38
40
 
39
41
  ```sh
40
42
  zinn project edit MDR --name "Macrodata Refinement (Morning Shift)"
43
+ zinn project edit MDR --description "Meet the quarterly quota"
44
+ zinn project edit MDR --description ""
41
45
  ```
42
46
 
43
- The `--name` flag is required. Names must contain printable text on a single line.
44
- Supplying the current name leaves the modification timestamp unchanged.
47
+ At least one of `--name` or `--description` is required. Names must contain printable text on a single line.
48
+ Only supplied fields change; unchanged values leave the modification timestamp unchanged.
45
49
  Use `--name="--example"` when a value begins with a dash.
46
50
 
47
51
  Add another column at the end of the board:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.34.0",
3
+ "version": "0.35.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.23.0"
45
+ "@zinn-dev/core": "0.24.0"
46
46
  }
47
47
  }
@@ -0,0 +1,15 @@
1
+ export function formatDescriptionPreview(description: string | null) {
2
+ const DESCRIPTION_PREVIEW_LENGTH = 80;
3
+
4
+ if (description == null) {
5
+ return "";
6
+ }
7
+
8
+ const normalizedDescription = description.replace(/\s+/g, " ").trim();
9
+
10
+ if (normalizedDescription.length <= DESCRIPTION_PREVIEW_LENGTH) {
11
+ return normalizedDescription;
12
+ }
13
+
14
+ return `${normalizedDescription.slice(0, DESCRIPTION_PREVIEW_LENGTH - 1).trimEnd()}…`;
15
+ }
@@ -2,23 +2,9 @@ import type { TaskPriority, TaskWithKey } from "@zinn-dev/core";
2
2
 
3
3
  import { column, task } from "@zinn-dev/core";
4
4
 
5
- import { TASK_DESCRIPTION_PREVIEW_LENGTH } from "../constant";
5
+ import { formatDescriptionPreview } from "./description-presentation";
6
6
  import { styleOutputText } from "./color";
7
7
 
8
- function formatTaskDescriptionPreview(description: string | null) {
9
- if (description == null) {
10
- return "";
11
- }
12
-
13
- const normalizedDescription = description.replace(/\s+/g, " ").trim();
14
-
15
- if (normalizedDescription.length <= TASK_DESCRIPTION_PREVIEW_LENGTH) {
16
- return normalizedDescription;
17
- }
18
-
19
- return `${normalizedDescription.slice(0, TASK_DESCRIPTION_PREVIEW_LENGTH - 1).trimEnd()}…`;
20
- }
21
-
22
8
  export type PresentedTask = {
23
9
  key: string;
24
10
  status: "Active" | "Archived";
@@ -107,7 +93,7 @@ export function formatTaskList(
107
93
  const status = options.showsStatus
108
94
  ? ` | ${presentedTask.status.padEnd(longestStatusLength)}`
109
95
  : "";
110
- const descriptionPreview = formatTaskDescriptionPreview(presentedTask.description);
96
+ const descriptionPreview = formatDescriptionPreview(presentedTask.description);
111
97
  const hasDescriptionPreview = descriptionPreview.length > 0;
112
98
  const description = hasDescriptionPreview ? ` | ${descriptionPreview}` : "";
113
99
  const priority = formatTaskPriorityMarker(presentedTask.priority);
@@ -12,17 +12,20 @@ import {
12
12
  validateUniqueOptions,
13
13
  } from "../lib";
14
14
  import { formatTaskList, presentTask } from "../presentation/task-presentation";
15
+ import { formatDescriptionPreview } from "../presentation/description-presentation";
15
16
  import { currentActor } from "../actor";
16
17
 
17
- type PresentedProject = { key: string; name: string };
18
+ type PresentedProject = { key: string; name: string; description: string | null };
18
19
  type PresentedProjectView = PresentedProject & { tasks: Array<PresentedTask> };
19
20
 
20
21
  function presentProject(projectMatch: PresentedProject): PresentedProject {
21
- return { key: projectMatch.key, name: projectMatch.name };
22
+ return { key: projectMatch.key, name: projectMatch.name, description: projectMatch.description };
22
23
  }
23
24
 
24
- function formatProject(presented: PresentedProject) {
25
- return `${presented.key} | ${presented.name}`;
25
+ function formatProject(presented: PresentedProject, keyWidth = presented.key.length) {
26
+ const descriptionPreview = formatDescriptionPreview(presented.description);
27
+ const description = descriptionPreview.length > 0 ? ` | ${descriptionPreview}` : "";
28
+ return `${presented.key.padEnd(keyWidth)} | ${presented.name}${description}`;
26
29
  }
27
30
 
28
31
  type PresentedColumn = { project: string; name: string };
@@ -42,7 +45,7 @@ export const projectRouter = {
42
45
  run: (args: Array<string>) => {
43
46
  const { values, positionals, tokens } = parseArgs({
44
47
  args,
45
- options: { name: { type: "string" } },
48
+ options: { name: { type: "string" }, description: { type: "string" } },
46
49
  allowPositionals: true,
47
50
  strict: true,
48
51
  tokens: true,
@@ -59,19 +62,23 @@ export const projectRouter = {
59
62
  validateUniqueOptions(tokens);
60
63
 
61
64
  try {
62
- const createdProject = project.create({ key: projectKey, name: values.name }, currentActor());
65
+ const createdProject = project.create(
66
+ { key: projectKey, name: values.name, description: values.description },
67
+ currentActor(),
68
+ );
63
69
  output(presentProject(createdProject), formatProject);
64
70
  } catch (err: any) {
65
71
  quit(err?.message ?? "Something went wrong");
66
72
  }
67
73
  },
68
- help: `Usage: zinn project create <project-key> [--name <text>]
74
+ help: `Usage: zinn project create <project-key> [--name <text>] [--description <text>]
69
75
 
70
76
  Create a project with the default columns.
71
77
  Project keys are stored in uppercase.
72
78
 
73
79
  An omitted name defaults to the uppercase project key.
74
80
  Names cannot be blank.
81
+ Descriptions may contain multiple lines. If omitted, they are saved as null.
75
82
 
76
83
  Example: zinn project create MDR --name "Macrodata Refinement"`,
77
84
  },
@@ -85,14 +92,12 @@ Example: zinn project create MDR --name "Macrodata Refinement"`,
85
92
  0,
86
93
  );
87
94
 
88
- return presentedProjects
89
- .map((p) => `${p.key.padEnd(longestKeyLength)} | ${p.name}`)
90
- .join("\n");
95
+ return presentedProjects.map((p) => formatProject(p, longestKeyLength)).join("\n");
91
96
  });
92
97
  },
93
98
  help: `Usage: zinn project list
94
99
 
95
- List projects and their keys.
100
+ List projects, their keys, and truncated description previews.
96
101
 
97
102
  Example: zinn project list`,
98
103
  },
@@ -134,7 +139,7 @@ Example: zinn project view MDR`,
134
139
  run: (args) => {
135
140
  const { values, positionals, tokens } = parseArgs({
136
141
  args,
137
- options: { name: { type: "string" } },
142
+ options: { name: { type: "string" }, description: { type: "string" } },
138
143
  allowPositionals: true,
139
144
  strict: true,
140
145
  tokens: true,
@@ -150,19 +155,21 @@ Example: zinn project view MDR`,
150
155
 
151
156
  validateUniqueOptions(tokens);
152
157
 
153
- if (values.name === undefined) {
154
- quit("Provide an edit flag: --name");
158
+ if (values.name === undefined && values.description === undefined) {
159
+ quit("Provide an edit flag: --name or --description");
155
160
  }
156
161
 
157
- const editedProject = project.edit({ projectKey, name: values.name }, currentActor());
162
+ const editedProject = project.edit(
163
+ { projectKey, name: values.name, description: values.description },
164
+ currentActor(),
165
+ );
158
166
  output(presentProject(editedProject), formatProject);
159
167
  },
160
- help: `Usage: zinn project edit <project-key> --name <text>
161
-
162
- Change the project name.
163
- The --name flag is required.
168
+ help: `Usage: zinn project edit <project-key> [--name <text>] [--description <text>]
164
169
 
165
- Unchanged names leave the modification timestamp unchanged.
170
+ Change the supplied project fields. At least one edit flag is required.
171
+ Use --description "" to clear the description to an empty string.
172
+ Omitted fields are preserved. Unchanged values leave the timestamp unchanged.
166
173
 
167
174
  Example: zinn project edit MDR --name "Macrodata Refinement"`,
168
175
  },
@@ -332,10 +339,7 @@ Example: zinn project column edit MDR "In Progress" --name "Refining"`,
332
339
  quit(`Order direction "${direction}" does not accept a target column`);
333
340
  }
334
341
 
335
- orderedColumn = column.order(
336
- { projectKey, columnName, direction },
337
- currentActor(),
338
- );
342
+ orderedColumn = column.order({ projectKey, columnName, direction }, currentActor());
339
343
  break;
340
344
  }
341
345
  default:
package/src/constant.ts DELETED
@@ -1 +0,0 @@
1
- export const TASK_DESCRIPTION_PREVIEW_LENGTH = 80;