oav/cli.ts

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

#!/usr/bin/env node
2018-05-30 07:33:36 +03:00
import * as yargs from 'yargs'
import * as os from 'os'
2018-05-30 04:14:35 +03:00
import { log } from './lib/util/logging'
2018-05-30 01:38:27 +03:00
let defaultLogDir = log.directory
let logFilepath = log.filepath
let packageVersion = require('./package.json').version
yargs
2017-04-29 06:19:22 +03:00
.version(packageVersion)
.commandDir('lib/commands')
2017-12-12 02:00:14 +03:00
.strict()
2017-04-29 06:19:22 +03:00
.option('h', { alias: 'help' })
.option('l', {
alias: 'logLevel',
describe: 'Set the logging level for console.',
2017-04-29 06:19:22 +03:00
choices: ['off', 'json', 'error', 'warn', 'info', 'verbose', 'debug', 'silly'],
2018-03-09 01:39:05 +03:00
default: 'info'
})
.option('f', {
alias: 'logFilepath',
2017-04-29 06:19:22 +03:00
describe: `Set the log file path. It must be an absolute filepath. ` +
2017-12-12 02:00:14 +03:00
`By default the logs will stored in a timestamp based log file at "${defaultLogDir}".`
})
.global(['h', 'l', 'f'])
.help()
2018-05-30 01:38:27 +03:00
.argv
if (yargs.argv._.length === 0 && yargs.argv.h === false) {
2018-05-30 01:38:27 +03:00
yargs.coerce('help', function (arg: any) { return true; }).argv
}