-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·29 lines (24 loc) · 732 Bytes
/
cli.js
File metadata and controls
executable file
·29 lines (24 loc) · 732 Bytes
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
#!/usr/bin/env node
const program = require("commander");
const cyberpun = require("./index");
program
.version("1.2.0", "-v, --version")
.option("-l, --list", "List all the jokes")
.option("-t, --tag <value>", "Filter jokes with tag");
program.on("--help", () => {
console.log(" Examples:");
console.log("");
console.log(" $ cyberpun");
console.log(" $ cyberpun --tag react");
console.log(" $ cyberpun -t javascript");
console.log(" $ cyberpun --list");
console.log(" $ cyberpun -l");
console.log(" $ cyberpun -lt react");
console.log("");
});
program.parse(process.argv);
console.log(
program.list
? cyberpun.list(program.tag).join("\n")
: cyberpun.random(program.tag)
);