-
Notifications
You must be signed in to change notification settings - Fork 55
/
cli.ts
38 lines (33 loc) · 1 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
#!/usr/bin/env node
import "reflect-metadata";
import * as yargs from "yargs";
import { log } from "./lib/util/logging";
const defaultLogDir = log.directory;
const packageVersion = require("../package.json").version;
// eslint-disable-next-line no-unused-expressions
yargs
.version(packageVersion)
.commandDir("lib/commands")
.strict()
.option("h", { alias: "help" })
.option("l", {
alias: "logLevel",
describe: "Set the logging level for console.",
choices: ["off", "json", "error", "warn", "info", "verbose", "debug", "silly"],
default: "info",
})
.option("f", {
alias: "logFilepath",
describe:
`Set the log file path. It must be an absolute filepath. ` +
`By default the logs will stored in a timestamp based log file at "${defaultLogDir}".`,
})
.option("p", {
alias: "pretty",
describe: `Pretty print`,
})
.global(["h", "l", "f", "p"])
.help().argv;
if (yargs.argv._.length === 0 && yargs.argv.h === false) {
yargs.coerce("help", (_) => true);
}