@zinn-dev/cli 0.31.0 → 0.32.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
@@ -263,6 +263,16 @@ zinn task unarchive MDR-1
263
263
 
264
264
  Delete a task permanently with `zinn task delete MDR-1`. It asks for confirmation before performing the action, unless `--yes` is used (see [Confirmations](#confirmations)).
265
265
 
266
+ ## Back up the database
267
+
268
+ It is recommended to save a copy of the database before installing a new version:
269
+
270
+ ```sh
271
+ zinn backup
272
+ ```
273
+
274
+ The copy goes to `~/.zinn/backups/` (or `backups/` in `ZINN_DIR`), in a file named after the UTC time and the CLI version that made it, like `2026-09-29T12-30-05Z-cli-0.32.0.sqlite`. It is a single file with every change made so far, and it is safe to take while Zinn is in use. Existing backups are never overwritten. With `--json`, the command prints `{ "path": "..." }`. It fails when there is no database yet.
275
+
266
276
  ## Scripting and JSON output
267
277
 
268
278
  Add `--json` to any command to get JSON instead of text. The flag can go anywhere in the command, except after `--`, where it is treated as a regular argument such as searching literally for `--json` in text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.31.0",
3
+ "version": "0.32.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.21.0"
45
+ "@zinn-dev/core": "0.22.0"
46
46
  }
47
47
  }
@@ -0,0 +1,23 @@
1
+ import type { Command } from "../types";
2
+
3
+ import { parseArgs } from "node:util";
4
+ import { backup } from "@zinn-dev/core";
5
+
6
+ import { output } from "../lib";
7
+ import packageJson from "../../package.json";
8
+
9
+ export const backupCommand = {
10
+ run: (args) => {
11
+ parseArgs({ args, strict: true, allowPositionals: false });
12
+
13
+ const created = backup.create({ client: "cli", version: packageJson.version });
14
+
15
+ output(created, (b) => `Saved a backup to ${b.path}`);
16
+ },
17
+ help: `Usage: zinn backup
18
+
19
+ Save a copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.
20
+
21
+ The copy includes recent writes and is safe to take while Zinn is in use.
22
+ Fails when there is no database yet. Existing backups are never overwritten.`,
23
+ } satisfies Command;
@@ -11,6 +11,7 @@ function toCommand(args: Array<string>) {
11
11
  }
12
12
 
13
13
  // Groups sibling commands into one line, e.g. " comment {create|list|edit|delete}".
14
+ // A command without siblings is not a choice, so it gets no braces, e.g. " backup".
14
15
  function formatCommands(parsedRoutes: Array<ParsedRoute>, prefix: string) {
15
16
  const siblingsByParent = new Map<string, Array<string>>();
16
17
  for (const { command } of parsedRoutes) {
@@ -24,7 +25,10 @@ function formatCommands(parsedRoutes: Array<ParsedRoute>, prefix: string) {
24
25
  }
25
26
 
26
27
  return [...siblingsByParent]
27
- .map(([parent, siblings]) => ` ${parent === "" ? "" : `${parent} `}{${siblings.join("|")}}`)
28
+ .map(([parent, siblings]) => {
29
+ const commands = siblings.length === 1 ? siblings[0] : `{${siblings.join("|")}}`;
30
+ return ` ${parent === "" ? "" : `${parent} `}${commands}`;
31
+ })
28
32
  .join("\n");
29
33
  }
30
34
 
@@ -1,10 +1,12 @@
1
1
  import { projectRouter } from "./project-router";
2
2
  import { taskRouter } from "./task-router";
3
3
  import { labelRouter } from "./label-router";
4
+ import { backupCommand } from "./backup-router";
4
5
 
5
6
  // TODO: lazy load?
6
7
  export const routes = {
7
8
  project: projectRouter,
8
9
  task: taskRouter,
9
10
  label: labelRouter,
11
+ backup: backupCommand,
10
12
  };