-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Design does not make it possible to process ordered flags #59
Comments
Does the order of the options not currently match the order arguments are found? |
I think ordered flags is unusual. Although I concede some commands may want to do this! The POSIX Utility Syntax Guidelines say:
|
Sometimes this is sufficient, but with complicated nuances. In some POSIX utilities (this includes
|
Aside from repeated options, the other case that is not covered by property order is import parse from 'minimist';
console.log(parse(process.argv.slice(2), { boolean: ['b'] })); % node index.mjs
{ _: [], b: false }
% node index.mjs -z -y -b -x
{ _: [], b: true, z: true, y: true, x: true } |
For interest, ordered flags is a use case that was considered for |
Adding something like |
Many POSIX coreutils have ordered flags. For example the
ls
command is able to perform multiple sorts, and the order of these sorts is determined by what order to provide the flags in.I'm not sure whether or not this will be considered out of scope for
minimist
, but I think it's worth pointing out and discussing because this module is used by popular packages likevorpal
and has potentially had a lot of influence on how CLI argument processing is done across node.js packages.The function would need to return an array instead of an object for this to work, so it would have to be an opt-in in the options object. I'm going to implement this either way so if I get the green light on this issue I'll contribute it here.
The text was updated successfully, but these errors were encountered: