forked from Azure/oav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
37 lines (31 loc) · 1.07 KB
/
cli.js
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
#!/usr/bin/env node
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
'use strict';
var yargs = require('yargs'),
os = require('os'),
log = require('./lib/util/logging');
var defaultLogDir = log.directory;
var logFilepath = log.filepath;
var packageVersion = require('./package.json').version;
yargs
.version(packageVersion)
.commandDir('lib/commands')
.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: 'warn'
})
.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}".`
})
.global(['h', 'l', 'f'])
.help()
.argv;
if (yargs.argv._.length === 0 && yargs.argv.h === false) {
yargs.coerce('help', function (arg) { return true; }).argv;
}