-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·50 lines (47 loc) · 1.46 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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
const cli = require('sywac')
.style(require('sywac-style-basic'))
.outputSettings({ maxWidth: 63 })
.preface(null, [
'Create a sywac CLI project in an idempotent way. This will add',
'sywac to your project with a default cli.js file. It will touch',
'package.json but will not overwrite files that already exist.'
].join('\n'))
.positional('[dir]', {
paramsDesc: 'Optional path to project directory'
})
.boolean('-a, --all', {
group: 'Scaffolding Options:',
desc: 'Scaffold all basic project files and dev dependencies'
})
.string('-d, --desc "Some desc"', {
group: 'Scaffolding Options:',
desc: 'Define project\'s initial description'
})
.string('-w, --wersion <x.y.z>', { // workaround for `npm init sywac -v x.y.z`
group: 'Scaffolding Options:',
desc: 'Define the project\'s initial version',
defaultValue: '0.1.0'
})
.help('-h, --help', {
group: 'Help Options:',
implicitCommand: false
})
.version('-V, --VERSION', {
group: 'Help Options:',
desc: 'Show create-sywac version number',
implicitCommand: false
})
.check((argv, ctx) => {
if (argv._.includes('--help') || argv._.includes('-h')) ctx.deferHelp()
else argv.version = argv.wersion
})
module.exports = cli
if (require.main === module) {
cli.parseAndExit().then(argv => {
return require('./index')(argv)
}).catch(err => {
console.error('Unexpected error:', err)
process.exit(1)
})
}