-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Make --help
and --version
work with allowUnknownFlags: false
#198
Conversation
Make `--help` and `--version` work with `allowUnknownFlags: false` Fixes: sindresorhusGH-197
Can you add tests? 🙏 |
--help
and --version
work with allowUnknownFlags: false
Yeah I thought of that right after I submitted this. 😄 |
See 368e760 for tests. Unfortunately, I think my change broke 20 other unrelated existing tests, so I may have to think of a better way to accomplish the fix without affecting other stuff. |
I have no idea if this makes sense whatsoever, because I don't understand how this is supposed to work.
OK, I got all the tests passing, but honestly I feel like I was hacking around without really understanding what the behavior should be. So someone should take a close look and make sure I didn't mess things up. |
let addedAutoVersion = false; | ||
|
||
if (options.autoHelp && !options.flags.help) { | ||
options.flags.help = {type: 'boolean'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are modifying the user's input object here. You should not do that.
@@ -129,6 +129,19 @@ const meow = (helpText, options = {}) => { | |||
...options, | |||
}; | |||
|
|||
let addedAutoHelp = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let addedAutoHelp = false; | |
let didAddAutoHelp = false; |
That someone is me and I don't think I'll time to review this in detail for quite some time, unfortunately. |
Currently, `allowUnknownFlags: false` is commented out, which is not ideal, because the error message the user gets when using an unknown flag is pretty confusing: ``` $ chalk --foobar Input required ``` The actual problem is in meow (see sindresorhus/meow#197), but it's been taking a while to come up with a proper fix for that (see sindresorhus/meow#198), so I suggest using this workaround in the meantime. See: chalk#32, chalk#33, chalk#39, sindresorhus/meow#197, sindresorhus/meow#198
|
||
Usage | ||
foo <input> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing for lack of activity. |
Make
--help
and--version
work withallowUnknownFlags: false
Fixes #197
Issue originally discovered with
chalk-cli
in chalk/chalk-cli#32