Disallow unknown options
sidvishnoi opened this issue · comments
Sid Vishnoi commented
It would be nice if there's a way to disallow unknown options. For example, mycommand --silent
should throw an error with:
sade("mycommand", true).option("-v, --verbose", "desc", false);
A hack/workaround I wrote is:
for (const key of Object.keys(opts)) {
if (!cli.tree.__all__.alias.hasOwnProperty(key) && key !== "_") {
const unknownOpt = key.length === 1 ? `-${key}` : `--${key}`;
throw new Error(`Unknown option: ${unknownOpt}`);
}
}
Luke Edwards commented
Hey, it already does :) It's a parse option:
Sid Vishnoi commented
Oh! Awesome!