-
-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
This is my basic setup:
import { cac } from "cac";
const cli = cac("cac");
cli
.command("", "")
.option("-c, --chars <chars>", "Characters")
.action(async (options) => {
console.log(options);
});
cli.help();
cli.version("1.0.0");
try {
cli.parse();
} catch (error) {
console.error(error);
process.exit(1);
}
When I pass -c 1234
:
{
"--": [],
c: 1234,
chars: 1234, // number
}
When I pass -c "1234"
(quoted):
{
"--": [],
c: 1234,
chars: 1234, // number
}
When I pass -c "abcdef"
:
{
"--": [],
c: "abcdef",
chars: "abcdef", // string
}
But when i pass "01234" again quoted, it treats it as a number again but also dropping the leading zero as it's a number now. This is odd to me.
"-c "01234"
:
{
"--": [],
c: 1234,
chars: 1234, // number
}
I would expect cac to treat my option always as a string
when it is quoted and don't even try to parse it as a number if it is quoted.
Metadata
Metadata
Assignees
Labels
No labels