-
Notifications
You must be signed in to change notification settings - Fork 620
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
bug(flags): collect is prioritised over boolean #2342
Comments
it takes this path https://github.com/denoland/deno_std/blob/main/flags/mod.ts#L340 setArg calls setkey which has collect=true as default |
If you specify arg name in
The above description should explain it. If you find the docs misleading/not clear, suggestions to the docs are welcome |
@kt3k But what is the point of collecting a boolean flag which always returns |
You can specify the same arg multiple times, like import { parse } from "https://deno.land/std@0.143.0/flags/mod.ts";
const a = parse(["-vvv"], { boolean: "verbose", collect: "verbose", alias: { v: "verbose" } });
console.log(a);
// => { _: [], v: [ true, true, true ], verbose: [ true, true, true ] } |
Is this a real use case? I have not encountered anything like that before. Looks more like it should throw an error since alias is not one char long. |
memcached has symfony (php tool) also seems having them https://symfony.com/doc/current/console/verbosity.html |
Looks to me like the aliases const args = parse(["-rrr"], { boolean: ["reload"], alias: { reload: "r"} }); as is const args = parse(["-rrr --reload"], { boolean: ["reload"], alias: { reload: "r"} }); Where as error: The argument '--reload[=<CACHE_BLOCKLIST>...]' was provided more than once, but cannot be used multiple times So imo this is also a bug. In any case, the flag mod seems overly complicated for what it does with boolean arrays and alias maps etc. |
I'm not in favor of changing Also std/flags is based on minimist, which has 20K+ dependent libraries. So the design can be considered very well battle tested. Changing this to completely new one only by a speculative reasoning doesn't look like an option to me. If we completely migrate to a new design, I think we should rather consider adopting another battle tested library such as |
Stale |
Describe the bug
Not sure if intentional or a bug: if boolean and collect is set for a flag, it will return
[true]
.boolean
should probably be higher prioritised thancollect
. Else it should be documented.Steps to Reproduce
parse returns
{ _:[], reload: [true] }
Expected behavior
parse should probably return
{ _:[], reload: true }
Environment
The text was updated successfully, but these errors were encountered: