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
Change on strict behaivor was a breaking change, a.k.a strict only for unknown options #1701
Comments
@fcastilloec we try to avoid it, but sometimes someone is relying on an edge-case of a feature that isn't covered appropriately by tests, and we accidentally break due to an oversight such as this. I would certainly be open to the idea of adding a new method like If you have the time, could you submit a failing test case for the behavior was working and began failing for you? |
We need to test for unknown options but allow unknown arguments See yargs/yargs#1701 and yargs/yargs#1710
Adds strictOptions() as a partner to strictCommands() Fixes #1701
@fcastilloec please try |
@bcoe Thanks! I just tried it and it's working in most cases but I found a bug when combined with: yargs(['foo', '-a'])
.parserConfiguration({ 'strip-aliased': true })
.strictOptions()
.option('and', { alias: 'A' })
.parse(); The previous code should fail but it passes. If you set See #1739 |
We need to test for unknown options but allow unknown arguments See yargs/yargs#1701 and yargs/yargs#1710
We need to test for unknown options but allow unknown arguments See yargs/yargs#1701 and yargs/yargs#1710
I know issue #1625 is closed and #1626 merged, but this was a breaking change (major version) from what
yargs
used to do and should have been properly labeled.I was actually using
strict
old behavior as the opposite ofstrictCommand
, in other words,strict
will only apply to unrecognized options and not commands/arguments.I had a command that takes various filenames, and I was counting on
strict
to display an error if the user used an unknown option but not on the filenames, which are seen as unknown arguments now.Now, I have the opposite problem of #1621, I can't use either
.strict()
or.strictCommand()
, and I can't prevent the user from adding unrecognized options.A workaround is to using
check
to manually see any unknow options and throw an error, but this is not ideal, especially becauseyargs
was able to do all this. This becomes even harder if you have many options in your command and you're using aliases and/or dashes.Perhaps, adding a
.strictOption()
method might be a good idea.The text was updated successfully, but these errors were encountered: