1 | require('hard-rejection/register')
|
2 | const updateNotifier = require('update-notifier')
|
3 | const yargs = require('yargs')
|
4 | const {join} = require('path')
|
5 | const {fromUrl} = require('hosted-git-info')
|
6 | const readPkgUp = require('read-pkg-up')
|
7 |
|
8 | module.exports.cli = async () => {
|
9 | const {pkg} = await readPkgUp({cwd: __dirname})
|
10 | process.title = Object.keys(pkg.bin)[0]
|
11 | updateNotifier({pkg}).notify()
|
12 | await yargs
|
13 | .usage('Usage: $0 <command>')
|
14 | .example('$0 --help <command>', 'Show command-specific options')
|
15 | .epilogue(`Documentation:\n ${fromUrl(pkg.repository.url).docs()}`)
|
16 | .commandDir(join(__dirname, 'commands'))
|
17 | .demandCommand(1)
|
18 | .help('help').alias('h', 'help')
|
19 | .version().alias('v', 'version')
|
20 | .wrap(null)
|
21 | .parse(process.argv.slice(2))
|
22 | }
|