@zinn-dev/cli 0.0.2 → 0.0.4

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 (3) hide show
  1. package/README.md +3 -0
  2. package/index.ts +46 -5
  3. package/package.json +6 -4
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @zinn-dev/cli
2
+
3
+ The `zinn` binary. Requires [Bun](https://bun.sh).
package/index.ts CHANGED
@@ -1,10 +1,51 @@
1
- // Main entry point, will replace the code currently published on https://www.npmjs.com/package/@zinn-dev/cli
2
-
1
+ #!/usr/bin/env bun
3
2
  const args = process.argv.slice(2);
3
+ const FLAG = {
4
+ help: ["-h", "--help"],
5
+ project: ["project"],
6
+ create: ["create"],
7
+ };
8
+
9
+ const MESSAGE = {
10
+ displayUnknownCommand: (cmd: string) =>
11
+ `Unrecognized command "${cmd}". Please run \`zinn --help\` for a list of available commands`,
12
+ };
4
13
 
5
14
  if (args.length === 0) {
6
- const tui = await import("@zinn-dev/tui");
7
- tui.launch();
15
+ if (!!process.stdout.isTTY) {
16
+ const tui = await import("@zinn-dev/tui");
17
+ tui.launch();
18
+ } else {
19
+ console.error("Direct launch in a non-TTY environment is not supported.");
20
+ process.exit(1);
21
+ }
8
22
  } else {
9
- // TODO: headless CLI
23
+ // TODO: isTTY check for human readable colored and structured formatting like tables
24
+ const firstArg = args[0]!;
25
+ if (FLAG.help.includes(firstArg)) {
26
+ console.log(`ZINN - A kanban workflow in the terminal
27
+
28
+ usage: zinn [options]
29
+ -h, --help For help using Zinn`);
30
+ } else {
31
+ const { createProject } = await import("@zinn-dev/core");
32
+
33
+ if (FLAG.project.includes(firstArg)) {
34
+ const secondArg = args[1];
35
+ if (secondArg == null) {
36
+ // TODO: implement `zinn project --help` for better guiding
37
+ console.error(
38
+ `The command "${firstArg}" requires a secondary command: zinn ${firstArg} <command>`,
39
+ );
40
+ process.exit(1);
41
+ } else if (FLAG.create.includes(secondArg)) {
42
+ createProject();
43
+ } else {
44
+ console.error(MESSAGE.displayUnknownCommand(`${firstArg} ${secondArg}`));
45
+ }
46
+ } else {
47
+ console.error(MESSAGE.displayUnknownCommand(firstArg));
48
+ process.exit(1);
49
+ }
50
+ }
10
51
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.0.2",
4
- "description": "A kanban workflow for your terminal. Built on OpenTUI.",
3
+ "version": "0.0.4",
4
+ "description": "A kanban workflow in the terminal.",
5
5
  "license": "MIT",
6
6
  "bugs": {
7
7
  "url": "https://github.com/yethranayeh/zinn/issues"
@@ -31,13 +31,15 @@
31
31
  }
32
32
  },
33
33
  "files": [
34
- "index.ts",
35
- "README.md"
34
+ "index.ts"
36
35
  ],
37
36
  "type": "module",
38
37
  "bin": {
39
38
  "zinn": "./index.ts"
40
39
  },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
41
43
  "dependencies": {
42
44
  "@zinn-dev/core": "0.0.1",
43
45
  "@zinn-dev/tui": "0.0.1"