-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcli.ts
43 lines (40 loc) · 1.35 KB
/
cli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { CreateProject } from "./commands/create.ts";
import { DevProject } from "./commands/dev.ts";
import { BuildProject } from "./commands/build.ts";
const command: { [key: string]: boolean } = { "create": true, "dev": true, "build": true, "start": true };
const { args: Args } = Deno;
const [cmd, appName, flag] = [Args[0], Args[1], Args[2]];
async function Main(appName: string, flag: string) {
try {
if (command[cmd]) {
switch (cmd) {
case "create":
appName ?
await CreateProject(appName, Deno.cwd(), flag) :
Main(`${prompt('Please enter App name: ', 'myApp')}`, flag);
break;
case "dev":
DevProject(appName);
break;
case "build":
await BuildProject(appName);
break;
}
}
else if (cmd === "--version" || cmd === "-v") {
console.log(`NOVAS 1.0`);
}
else {
console.log(`To create a project, type:` + ` %cNOVAS create ` + `%c[project name]`, "color:#55dac8;", "color:red;");
console.log(`To compile a project, type:` + ` %cNOVAS build`, "color:#55dac8;");
console.log(`To start a dev server, type:` + ` %cNOVAS dev`, "color:#55dac8;");
}
} catch (error) {
if (!(error instanceof Deno.errors.NotFound)) {
console.log(error);
}
}
}
if (import.meta.main) {
await Main(appName, flag);
}