@zinn-dev/cli 0.23.0 → 0.24.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
@@ -60,6 +60,21 @@ Columns are matched by name, and matching is case-insenstivie. Names are trimmed
60
60
  Since columns are case-insensitive, you cannot have two columns with only different casing such as `todo` and `Todo`. However, you are free to change the casing of an existing column.
61
61
  Tasks stay in the renamed column.
62
62
 
63
+ Change a column's position on the board:
64
+
65
+ ```sh
66
+ zinn project column order MDR Review first
67
+ zinn project column order MDR Review previous
68
+ zinn project column order MDR Review next
69
+ zinn project column order MDR Review last
70
+ zinn project column order MDR Review before "In Progress"
71
+ zinn project column order MDR Review after Done
72
+ ```
73
+
74
+ Directions follow board order: `first` is the start of the board and `last` is its end.
75
+ Both the column and the target of `before` or `after` are matched by name, and matching is case-insensitive.
76
+ Moving a column to the position it already has, or before or after itself, does nothing. Tasks stay in their columns.
77
+
63
78
  `zinn project delete MDR` asks for confirmation, then permanently deletes the project and all of its columns and tasks.
64
79
 
65
80
  ## Create and read tasks
package/index.ts CHANGED
@@ -26,6 +26,7 @@ Commands:
26
26
  project column create
27
27
  project column edit
28
28
  project column list
29
+ project column order
29
30
  task create
30
31
  task list
31
32
  task search
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.23.0",
3
+ "version": "0.24.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.16.0"
45
+ "@zinn-dev/core": "0.17.0"
46
46
  }
47
47
  }
@@ -24,6 +24,18 @@ function formatProject(presented: PresentedProject) {
24
24
  return `${presented.key} | ${presented.name}`;
25
25
  }
26
26
 
27
+ type PresentedColumn = { project: string; name: string };
28
+
29
+ function presentColumn(columnMatch: { project_id: string; name: string }): PresentedColumn {
30
+ const columnProject = project.getById(columnMatch.project_id)!;
31
+
32
+ return { project: columnProject.key, name: columnMatch.name };
33
+ }
34
+
35
+ function formatColumn(presented: PresentedColumn) {
36
+ return `${presented.project} | ${presented.name}`;
37
+ }
38
+
27
39
  export const projectRouter = {
28
40
  edit: {
29
41
  run: (args) => {
@@ -201,10 +213,7 @@ Example: zinn project delete MDR`,
201
213
 
202
214
  try {
203
215
  const createdColumn = column.create({ projectKey, name: columnName });
204
- const columnProject = project.getById(createdColumn.project_id)!;
205
- const presentedColumn = { project: columnProject.key, name: createdColumn.name };
206
-
207
- output(presentedColumn, (c) => `${c.project} | ${c.name}`);
216
+ output(presentColumn(createdColumn), formatColumn);
208
217
  } catch (err: any) {
209
218
  quit(err?.message ?? "Something went wrong");
210
219
  }
@@ -242,10 +251,7 @@ Example: zinn project column create MDR "Boardlog"`,
242
251
  columnName: positionals[1]!,
243
252
  name: values.name,
244
253
  });
245
- const columnProject = project.getById(editedColumn.project_id)!;
246
- const presentedColumn = { project: columnProject.key, name: editedColumn.name };
247
-
248
- output(presentedColumn, (c) => `${c.project} | ${c.name}`);
254
+ output(presentColumn(editedColumn), formatColumn);
249
255
  },
250
256
  help: `Usage: zinn project column edit <project-key> <column-name> --name <text>
251
257
 
@@ -257,6 +263,63 @@ Names are trimmed, and must remain unique within the same project.
257
263
  Changing only the casing of a column's own name is allowed.
258
264
 
259
265
  Example: zinn project column edit MDR "In Progress" --name "Refining"`,
266
+ },
267
+ order: {
268
+ run: (args: Array<string>) => {
269
+ const [projectKey, columnName, direction, targetColumnName, ...extraArgs] = args;
270
+
271
+ if (projectKey == null || columnName == null) {
272
+ quit("Both the project key and the column name must be specified");
273
+ }
274
+
275
+ if (direction == null) {
276
+ quit("Order direction must be specified");
277
+ }
278
+
279
+ let orderedColumn: ReturnType<typeof column.order>;
280
+
281
+ switch (direction) {
282
+ case "before":
283
+ case "after": {
284
+ if (targetColumnName == null) {
285
+ quit(`Target column must be specified for "${direction}"`);
286
+ }
287
+
288
+ if (extraArgs.length > 0) {
289
+ quit("Only one target column can be specified");
290
+ }
291
+
292
+ orderedColumn = column.order({ projectKey, columnName, direction, targetColumnName });
293
+ break;
294
+ }
295
+ case "first":
296
+ case "previous":
297
+ case "next":
298
+ case "last": {
299
+ if (targetColumnName != null) {
300
+ quit(`Order direction "${direction}" does not accept a target column`);
301
+ }
302
+
303
+ orderedColumn = column.order({ projectKey, columnName, direction });
304
+ break;
305
+ }
306
+ default:
307
+ quit(`Unknown order direction "${direction}"`);
308
+ }
309
+
310
+ // TODO: maybe also print the new full column state?
311
+ output(presentColumn(orderedColumn), formatColumn);
312
+ },
313
+ help: `Usage: zinn project column order <project-key> <column-name> <first | previous | next | last>
314
+ zinn project column order <project-key> <column-name> <before | after> <target-column-name>
315
+
316
+ Change a column's position on the project's board.
317
+ Use first or last for either end, previous or next for one position,
318
+ or before or after to place it relative to another column.
319
+
320
+ Columns are matched by name, and matching is case-insensitive.
321
+
322
+ Example: zinn project column order MDR Review before "In Progress"`,
260
323
  },
261
324
  list: {
262
325
  run: (args: Array<string>) => {