-
Notifications
You must be signed in to change notification settings - Fork 993
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
Options appear in the order of defintion #39
Comments
The order of keys in the return value of |
You can just sort the result from keys? |
@megawac how does that help? That'll just sort them alphabetically: they need to be sorted according to the order of their appearance on the command-line. @codelahoma last time I checked, yargs was meant to only work with nodejs, but maybe it works with other things, however, I only would use it with nodejs. Closing this issue since it'll never be taken seriously by the people in charge of this repo. |
@amagura I definitely take this issue seriously, it's just a hard problem and I've been wrapped up working on a few big refactors. Correct me if I'm wrong @codelahoma, in V8 |
@bcoe It's been hotly debated for over six years, but V8 does not always follow insertion order, and they continue to say it's WorkingAsIntended. |
@bcoe my apologies, I was just a little frustrated at the time. |
It would be really cool if it was possible to retrieve the arguments in the order they appear.
But I'm not sure how it should be exposed. Maybe provide |
This appears to be implemented and working now?! |
|
Problem Description
Options in the hash produced by yargs appear in the order in which they were defined, rather than in the order in which they appeared on the command-line: this makes it impossible to determine which option(s)/operand(s) should be handled first.
Example
Consider the following example were both
-h
and-V
are mutually exclusive in the sense that the program exits immediately after they occur.No matter what order I put the options in, unless
-V
is passed by itself, it will never get handled because-h
is defined before-V
, and note that even if you change thedescribe(...)
settings around so that-V
is defined before-h
, if you don't also update the.boolean(...)
settings, then-h
will still be defined before-V
.Proposed Solution
You can probably fix the above by simply adding options as they appear on the command-line, like so:
The text was updated successfully, but these errors were encountered: