We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Program option -v/--version is not supported in reliable way.
-v
--version
Consider the following sample program:
const app = require('commander'); app .option('-v, --version [id]', 'version identifier to use (optional)') .action((options) => { console.log(options.version); }); app.parse(process.argv);
This will be the output -
~/work/commander-test > node app.js --version 42 42 ~/work/commander-test > node app.js [Function: version] ~/work/commander-test >
Note that options.version is always defined, even if not provided, defaulting to a function (my guess that it is https://github.com/tj/commander.js/tree/v5.0.0#version-option).
options.version
Side effect of the above is that I cannot mark -v option as required - it does not error out, since it is always implicitly defined.
The text was updated successfully, but these errors were encountered:
Clashing option names with properties on the Command object is a problem, with collected issues in #933
The good news is there is a solution now! See .storeOptionsAsProperties(false) and the section in the README:
.storeOptionsAsProperties(false)
https://github.com/tj/commander.js#avoiding-option-name-clashes
Sorry, something went wrong.
Thank you, this solves the problem for me!
Opened a PR to add a warning for option name clashes: #1275
No branches or pull requests
Program option
-v
/--version
is not supported in reliable way.Consider the following sample program:
This will be the output -
Note that
options.version
is always defined, even if not provided, defaulting to a function (my guess that it is https://github.com/tj/commander.js/tree/v5.0.0#version-option).Side effect of the above is that I cannot mark
-v
option as required - it does not error out, since it is always implicitly defined.The text was updated successfully, but these errors were encountered: