2017-02-02 07:46:56 +03:00
|
|
|
#!/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'
|
2017-01-17 09:14:02 +03:00
|
|
|
|
2018-05-30 01:38:27 +03:00
|
|
|
let defaultLogDir = log.directory
|
|
|
|
let logFilepath = log.filepath
|
|
|
|
let packageVersion = require('./package.json').version
|
2017-02-02 07:46:56 +03:00
|
|
|
|
2017-01-17 09:14:02 +03:00
|
|
|
yargs
|
2017-04-29 06:19:22 +03:00
|
|
|
.version(packageVersion)
|
2017-01-17 09:14:02 +03:00
|
|
|
.commandDir('lib/commands')
|
2017-12-12 02:00:14 +03:00
|
|
|
.strict()
|
2017-04-29 06:19:22 +03:00
|
|
|
.option('h', { alias: 'help' })
|
2017-02-02 07:46:56 +03:00
|
|
|
.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'
|
2017-02-02 07:46:56 +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. ` +
|
2017-12-12 02:00:14 +03:00
|
|
|
`By default the logs will stored in a timestamp based log file at "${defaultLogDir}".`
|
2017-02-02 07:46:56 +03:00
|
|
|
})
|
2017-02-24 22:06:31 +03:00
|
|
|
.global(['h', 'l', 'f'])
|
2017-01-17 09:14:02 +03:00
|
|
|
.help()
|
2018-05-30 01:38:27 +03:00
|
|
|
.argv
|
2017-01-17 09:14:02 +03:00
|
|
|
|
2017-02-24 22:06:31 +03:00
|
|
|
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
|
2017-01-24 08:16:27 +03:00
|
|
|
}
|