core
core copied to clipboard
Adding `strict=false` parses a non-existing flag as a `arg`
Describe the bug
When you disable argument validation with static strict = false it causes non-existing or misspelled flags to be parsed as args.
To Reproduce
-
static strict = false;to a command (docs) - Parse the arguments on the command and log them to the console
const {argv} = await this.parse(MyCLI)
console.log('Args:', argv)
- Run the command with a misspelled flag:
bin/dev my:command --hekp - Notice that
--hekpis parsed as aarginstead of getting a warning such as:Flag '--hekp' does not exist
Expected behavior
I think that it makes the most sense to treat all arguments that start with hyphens (- or --) as flags even if strict = false is used.
Additional context
This would very likely be a breaking change. Someone out there may be using args that start with hyphens. Let's fix this in v2, will add GitHub label.