Open greentore opened 10 months ago
I investigated this issue a bit more and turns out cliffy is always parsing empty strings as arguments regardless of context.
import { Command } from "jsr:@cliffy/command@^1.0.0-rc.4";
const cli = new Command()
.arguments("[a]")
.option(
"-A, --A [a]",
"A",
)
.action((opts, ...args) => {
console.log(opts);
console.log(args);
});
cli.parse(["-A", ""]);
// { A: true }
// [ "" ]
cli.parse(["-A", " "]);
// { A: " " }
// []
An aside, but seems like short flag only options are broken at the moment. "-A [a]"
resulted in name being an empty string.
Passing an empty string (
""
) to an option with a required value results in an error. In case of optional value the string is ignored and you gettrue
instead. Is it a bug or working as intended?