-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello-world.js
40 lines (32 loc) · 1023 Bytes
/
hello-world.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
#!/usr/bin/env node
// YOUR APP
function hello(resp) {
if (resp.help === true) return this.printCommandGuide("hello");
console.log("Hello,", resp.output);
}
function goodbye(resp) {
if (resp.help === true) return this.printCommandGuide("goodbye");
console.log("Goodbye,", resp.output);
}
// YOUR CLI
const cli = require("../bin/spawn");
// theme
cli.header("\nHELLO WORLD").themeColor("green");
// Hello
cli
.command("hello", "Prints hello")
.argument("output", "o", "Text to output")
.argument("help", "h", "Output help", false)
.callback(hello)
.example("hello -o=World!", "Prints Hello World!");
// Goodbye
cli
.command("goodbye", "Prints hello")
.argument("output", "o", "Text to output")
.argument("help", "h", "Output help", false)
.callback(goodbye)
.example("goodbye -o=World!", "Prints Goodbye World!");
// Use the automated guide
cli.command("guide", "Prints guide").callback(cli.printGuide);
// Start
cli.defaultCommand("guide").run();