You can support for -v
instead of -V
to get the --version
to be consistent with Node and npm.
It's just a customization:
.version('1.0.0', '-v, --version')
If the flags aren't specified, they just default to -V, --version.
const commander = require( 'commander' ); | |
const packageJson = require( './package.json' ); | |
const program = new commander.Command( packageJson.name ) | |
.version( packageJson.version, '-v, --version' ) | |
.parse( process.argv ); |
I've since learned that commander.js was not allowing the name of the long option to be changed (e.g.,
--revision
). I've submitted a patch to support this.