Skip to content
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

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

Closed
iowillhoit opened this issue Oct 17, 2022 · 0 comments · Fixed by #539 or #588
Closed

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

iowillhoit opened this issue Oct 17, 2022 · 0 comments · Fixed by #539 or #588

Comments

@iowillhoit
Copy link
Contributor

iowillhoit commented Oct 17, 2022

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.

@mdonnalley mdonnalley changed the title Adding strict=false parses a non-existing flag as a vararg Adding strict=false parses a non-existing flag as a arg Oct 28, 2022
@mdonnalley mdonnalley mentioned this issue Oct 28, 2022
8 tasks
@mdonnalley mdonnalley mentioned this issue Jan 12, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant