Skip to content
New issue

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

Cannot override version option without explicitly specifying the version value #416

Closed
nexdrew opened this issue Mar 4, 2016 · 1 comment

Comments

@nexdrew
Copy link
Member

nexdrew commented Mar 4, 2016

Perhaps my expectations are misplaced, but I find the current .version() API to be very confusing. Based on the docs:

.VERSION([OPTION], [DESCRIPTION], [VERSION])

I would expect to be able to do this:

var argv = require('yargs').version('V').argv
$ node test-version.js -V
1.0.0 # or whatever version is in package.json

But instead the first argument is treated as the version value and I cannot override the --version option:

$ node test-version.js --version
V

At the very least, we should clarify the expected behavior in the docs.

At the worst, this confuses and frustrates users, seeming to undo the work done in #330 (meant to address #329) that was supposed to make the API more consistent with, e.g., .help('H').

We also have no tests for the version method accepting a single argument, but based on this comment I thought my expectations of .version('V') were correct - so I could not validate them based on documentation or tests.

The best I can seem to do is:

var argv = require('yargs').version().alias('V', 'version').argv

Which is perfectly acceptable, but I just find the API confusing, and it would be nice to be able to completely override --version without having to do the package.json lookup manually.

@bcoe
Copy link
Member

bcoe commented Sep 24, 2020

closed in favor of, #1660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants