-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 1.17 KB
/
index.js
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
const chalk = require("chalk");
const { program } = require("commander");
const handlePlatformInit = require("./init/platformInit");
const createProject = require("./utils/createProject");
const updateProject = require("./utils/updateProject");
program.name("nucbot").description("Nucbot CLI tool").version("1.0.0");
program
.command("init")
.description("Initialize a new project")
.option("-p, --platform <type>", "specify the platform")
.option("-n, --name <name>", "enter a project name")
.action(async (options) => {
if (!options.platform && !options.name) {
handlePlatformInit();
} else {
createProject(options.name, options.platform);
}
});
program
.command("update")
.description("Update project")
.action(() => {
updateProject("platform");
console.log("Updating project components...");
});
program.on("command:*", () => {
console.error(chalk.red("Invalid command."));
console.log(chalk.yellow("\nAvailable commands:"));
console.log(" init Initialize a new project");
console.log(" update Update project components");
process.exit(1);
});
program.parse(process.argv);
if (!process.argv.slice(2).length) {
program.outputHelp();
}