@zinn-dev/cli 0.1.0 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A kanban workflow in the terminal.",
5
5
  "license": "MIT",
6
6
  "bugs": {
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@zinn-dev/core": "0.1.0",
45
+ "@zinn-dev/core": "0.2.0",
46
46
  "@zinn-dev/tui": "0.0.1"
47
47
  }
48
48
  }
@@ -15,7 +15,8 @@ export const projectRouter = {
15
15
  }
16
16
 
17
17
  try {
18
- project.create({ key: projectKey, name: projectName });
18
+ const createdProject = project.create({ key: projectKey, name: projectName });
19
+ console.info(`${createdProject.key} | ${createdProject.name}`);
19
20
  } catch (err: any) {
20
21
  quit(err?.message ?? "Something went wrong");
21
22
  }
@@ -57,7 +58,8 @@ Example: zinn project list`,
57
58
 
58
59
  try {
59
60
  // TODO: add y/n confirmation
60
- project.delete(projectKey);
61
+ const deletedProject = project.delete(projectKey);
62
+ console.info(`Deleted ${deletedProject.key} | ${deletedProject.name}`);
61
63
  } catch (err: any) {
62
64
  quit(err?.message ?? "Something went wrong");
63
65
  }
@@ -79,7 +81,10 @@ Example: zinn project delete SITE`,
79
81
  }
80
82
 
81
83
  try {
82
- column.create({ projectKey, name: columnName });
84
+ const createdColumn = column.create({ projectKey, name: columnName });
85
+ const columnProject = project.getById(createdColumn.project_id)!;
86
+
87
+ console.info(`${columnProject.key} | ${createdColumn.name}`);
83
88
  } catch (err: any) {
84
89
  quit(err?.message ?? "Something went wrong");
85
90
  }
@@ -5,6 +5,21 @@ import { parseArgs } from "node:util";
5
5
  import { task, project, column } from "@zinn-dev/core";
6
6
  import { quit } from "../lib";
7
7
 
8
+ function formatTask(
9
+ taskMatch: ReturnType<typeof task.getByKey>,
10
+ options: { showsStatus?: boolean } = {},
11
+ ) {
12
+ const taskProject = project.getById(taskMatch.project_id)!;
13
+ const taskColumn = column.getById(taskMatch.column_id)!;
14
+ const taskKey = `${taskProject.key}-${taskMatch.number}`;
15
+ const status = options.showsStatus
16
+ ? ` | ${taskMatch.archived_at == null ? "Active" : "Archived"}`
17
+ : "";
18
+ const description = taskMatch.description == null ? "" : ` | ${taskMatch.description}`;
19
+
20
+ return `${taskKey}${status} | ${taskColumn.name} | ${taskMatch.title}${description}`;
21
+ }
22
+
8
23
  export const taskRouter = {
9
24
  edit: {
10
25
  run: (args) => {
@@ -43,7 +58,8 @@ export const taskRouter = {
43
58
  quit("Provide at least one edit flag: --title or --description");
44
59
  }
45
60
 
46
- task.edit({ taskKey, ...values });
61
+ const editedTask = task.edit({ taskKey, ...values });
62
+ console.info(formatTask(editedTask));
47
63
  },
48
64
  help: `Usage: zinn task edit <task-key> [--title <text>] [--description <text>]
49
65
 
@@ -81,11 +97,12 @@ Example: zinn task edit SITE-1 --title "Rewrite the landing page"`,
81
97
  }
82
98
 
83
99
  // TODO: should it non-null (??) or non-falsy (||) check?
84
- task.create({
100
+ const createdTask = task.create({
85
101
  project_id: projectMatch.id,
86
102
  title: taskTitle,
87
103
  description: taskDesc ?? null,
88
104
  });
105
+ console.info(formatTask(createdTask));
89
106
  } catch (err: any) {
90
107
  quit(err?.message ?? "Something went wrong");
91
108
  }
@@ -171,12 +188,7 @@ Example: zinn task list SITE --all`,
171
188
  }
172
189
 
173
190
  const taskMatch = task.getByKey(taskKey);
174
- const taskProject = project.getById(taskMatch.project_id)!;
175
- const taskColumn = column.getById(taskMatch.column_id)!;
176
-
177
- const canonicalTaskKey = `${taskProject.key}-${taskMatch.number}`;
178
- const description = taskMatch.description == null ? "" : ` | ${taskMatch.description}`;
179
- console.info(`${canonicalTaskKey} | ${taskColumn?.name} | ${taskMatch.title}${description}`);
191
+ console.info(formatTask(taskMatch));
180
192
  },
181
193
  help: `Usage: zinn task view <task-key>
182
194
 
@@ -196,7 +208,8 @@ Example: zinn task view SITE-1`,
196
208
  quit("Target column must be specified");
197
209
  }
198
210
 
199
- task.move({ taskKey, targetColumn });
211
+ const movedTask = task.move({ taskKey, targetColumn });
212
+ console.info(formatTask(movedTask));
200
213
  },
201
214
  help: `Usage: zinn task move <task-key> <target-column>
202
215
 
@@ -232,7 +245,8 @@ Example: zinn task move SITE-1 "In Progress"`,
232
245
  quit("Only one target task can be specified");
233
246
  }
234
247
 
235
- task.order({ taskKey, direction, targetTaskKey });
248
+ const orderedTask = task.order({ taskKey, direction, targetTaskKey });
249
+ console.info(formatTask(orderedTask));
236
250
  return;
237
251
  }
238
252
  case "top":
@@ -243,7 +257,8 @@ Example: zinn task move SITE-1 "In Progress"`,
243
257
  quit(`Order direction "${direction}" does not accept a target task`);
244
258
  }
245
259
 
246
- task.order({ taskKey, direction });
260
+ const orderedTask = task.order({ taskKey, direction });
261
+ console.info(formatTask(orderedTask));
247
262
  return;
248
263
  }
249
264
  default:
@@ -268,11 +283,14 @@ Example: zinn task order SITE-2 before SITE-1`,
268
283
  }
269
284
 
270
285
  try {
271
- task.getByKey(taskKey);
286
+ const taskMatch = task.getByKey(taskKey);
272
287
  const canDelete = confirm(`Are you sure you want to delete ${taskKey}?`);
273
288
 
274
289
  if (canDelete) {
275
- task.delete(taskKey);
290
+ const deletedTask = task.delete(taskKey);
291
+ console.info(`Deleted ${formatTask(deletedTask)}`);
292
+ } else {
293
+ console.info(`Deletion cancelled for ${formatTask(taskMatch)}`);
276
294
  }
277
295
  } catch (err: any) {
278
296
  quit(err?.message ?? "Something went wrong");
@@ -292,7 +310,8 @@ Example: zinn task delete SITE-1`,
292
310
  quit("Task key must be specified");
293
311
  }
294
312
 
295
- task.archive(taskKey);
313
+ const archivedTask = task.archive(taskKey);
314
+ console.info(formatTask(archivedTask, { showsStatus: true }));
296
315
  },
297
316
  help: `Usage: zinn task archive <task-key>
298
317
 
@@ -308,7 +327,8 @@ Example: zinn task archive SITE-1`,
308
327
  quit("Task key must be specified");
309
328
  }
310
329
 
311
- task.unarchive(taskKey);
330
+ const unarchivedTask = task.unarchive(taskKey);
331
+ console.info(formatTask(unarchivedTask, { showsStatus: true }));
312
332
  },
313
333
  help: `Usage: zinn task unarchive <task-key>
314
334