-
Notifications
You must be signed in to change notification settings - Fork 633
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): boolean flag doesn't equal assigned value #2341
Comments
Maybe this check https://github.com/denoland/deno_std/blob/main/flags/mod.ts#L310 should just be removed and always run |
I think the returned result is correct here because
But i noticed the values for short flags are wrong: import { parse } from "https://deno.land/std@0.143.0/flags/mod.ts";
const args1 = parse(["-r=value"], { boolean: ["r"] });
const args2 = parse(["-r=value"], {
boolean: ["reload"],
alias: { reload: ["r"] },
}); args1 returns Expected behavior |
Oh, that is kinda strange. What if you want some flags to behave like you set What if we redesigned the parse options to something more intuitive and with a better overview with objects that represent flags? For example: parse(args, {
flags: [
{
name: "reload",
alias: "r",
converter(value: string) { return value == null || value }
},
{
name: "some-list",
default: "a,b,c",
args: [{ name: "list" }],
converter(value: string) { return value.split(",") }
},
{
name: "log-level",
description: `Set log level [possible values: debug, info]`,
alias: "L",
args: [{ name: "log-level" }],
}
]
}) |
Stale |
Describe the bug
A flag which is set as a boolean shouldn't be parsed as a boolean if it has a value assigned with the equals sign as described:
Steps to Reproduce
parse returns
{ _:[], reload: true }
Expected behavior
parse should return
{ _:[], reload: "value" }
Environment
The text was updated successfully, but these errors were encountered: