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