-
-
Save egoist/069d26e4b51ff984a7d80a471136d4ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cli = require('cac') | |
// call cli.option to add global options | |
cli.option({ | |
name: 'cool', | |
desc: 'Make CLI cool again', | |
required: true, | |
type: String | |
}) | |
cli.option({ | |
name: 'wow,w', | |
desc: 'Say wow', | |
type: Boolean | |
}) | |
cli.command({ | |
name: 'build', | |
// Basically `cmd` == `cli` but with command context | |
// i.e. it only adds options to this command | |
builder: cmd => cmd.option({ | |
name: 'production,p', | |
default: true, | |
desc: 'Minimize code' | |
}), | |
handler: (args, flags) => { | |
console.log(flags.p) // true | |
} | |
}) | |
cli.parse(process.argv) |
The debug logger could be very useful too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cli.option
adds global option,cmd.option
adds command option.