@zinn-dev/cli 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/index.ts +44 -2
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env bun
2
+
2
3
  const args = process.argv.slice(2);
3
4
  const FLAG = {
4
5
  help: ["-h", "--help"],
5
6
  project: ["project"],
6
7
  create: ["create"],
8
+ delete: ["delete"],
7
9
  };
8
10
 
9
11
  const MESSAGE = {
@@ -23,12 +25,13 @@ if (args.length === 0) {
23
25
  // TODO: isTTY check for human readable colored and structured formatting like tables
24
26
  const firstArg = args[0]!;
25
27
  if (FLAG.help.includes(firstArg)) {
28
+ // TODO: document that project keys are always uppercased
26
29
  console.log(`ZINN - A kanban workflow in the terminal
27
30
 
28
31
  usage: zinn [options]
29
32
  -h, --help For help using Zinn`);
30
33
  } else {
31
- const { createProject } = await import("@zinn-dev/core");
34
+ const { createProject, deleteProject } = await import("@zinn-dev/core");
32
35
 
33
36
  if (FLAG.project.includes(firstArg)) {
34
37
  const secondArg = args[1];
@@ -39,9 +42,48 @@ if (args.length === 0) {
39
42
  );
40
43
  process.exit(1);
41
44
  } else if (FLAG.create.includes(secondArg)) {
42
- createProject();
45
+ // TODO: allow direct key value pairs with flags like --name and --key
46
+ const projectName = args[2];
47
+ // TODO: maybe auto generate project key from name instead of forcing explicit input (however, very open to collision)
48
+ const projectKey = args[3];
49
+
50
+ if (projectName == null || projectKey == null) {
51
+ console.error("Both the project name and the project key must be defined");
52
+ process.exit(1);
53
+ }
54
+
55
+ try {
56
+ createProject(projectKey, projectName);
57
+ } catch (err) {
58
+ if (err instanceof Error) {
59
+ console.error(err.message);
60
+ } else {
61
+ console.error(err);
62
+ }
63
+ process.exit(1);
64
+ }
65
+ } else if (FLAG.delete.includes(secondArg)) {
66
+ const projectKey = args[2];
67
+ if (projectKey == null) {
68
+ console.error("You need to specificy which project to delete");
69
+ process.exit(1);
70
+ }
71
+
72
+ try {
73
+ // TODO: add y/n confirmation
74
+ deleteProject(projectKey);
75
+ } catch (err) {
76
+ if (err instanceof Error) {
77
+ console.error(err.message);
78
+ } else {
79
+ console.error(err);
80
+ }
81
+
82
+ process.exit(1);
83
+ }
43
84
  } else {
44
85
  console.error(MESSAGE.displayUnknownCommand(`${firstArg} ${secondArg}`));
86
+ process.exit(1);
45
87
  }
46
88
  } else {
47
89
  console.error(MESSAGE.displayUnknownCommand(firstArg));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A kanban workflow in the terminal.",
5
5
  "license": "MIT",
6
6
  "bugs": {