oav/cli.ts

39 строки
965 B
TypeScript
Исходник Обычный вид История

#!/usr/bin/env node
2018-06-09 02:35:55 +03:00
/* tslint:disable */
2018-06-02 03:26:20 +03:00
import * as yargs from "yargs"
import { log } from "./lib/util/logging"
2018-05-30 09:53:02 +03:00
const defaultLogDir = log.directory
2018-06-02 03:26:20 +03:00
2018-06-09 02:35:55 +03:00
const packageVersion = require("../package.json").version
yargs
2017-04-29 06:19:22 +03:00
.version(packageVersion)
2018-06-02 03:26:20 +03:00
.commandDir("lib/commands")
2017-12-12 02:00:14 +03:00
.strict()
2018-06-02 03:26:20 +03:00
.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",
})
2018-06-02 03:26:20 +03:00
.option("f", {
alias: "logFilepath",
2017-04-29 06:19:22 +03:00
describe: `Set the log file path. It must be an absolute filepath. ` +
2018-06-02 03:26:20 +03:00
`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()
2018-06-09 02:35:55 +03:00
.argv;
if (yargs.argv._.length === 0 && yargs.argv.h === false) {
yargs.coerce("help", _ => true).argv;
2018-06-02 03:26:20 +03:00
}