core icon indicating copy to clipboard operation
core copied to clipboard

Adding `strict=false` parses a non-existing flag as a `arg`

Open iowillhoit opened this issue 3 years ago • 0 comments

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

  1. static strict = false; to a command (docs)
  2. Parse the arguments on the command and log them to the console
const {argv} = await this.parse(MyCLI)
console.log('Args:', argv)
  1. Run the command with a misspelled flag: bin/dev my:command --hekp
  2. Notice that --hekp is parsed as a arg instead 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.

iowillhoit avatar Oct 17 '22 19:10 iowillhoit