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

feat: requiresArg is now simply an alias for nargs(1) #1054

Merged
merged 1 commit into from Jan 22, 2018

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented Jan 20, 2018

BREAKING CHANGE: requiresArg now has significantly different error output, matching nargs.

based on @evocateur's clever suggestion, requiresArg is now just an alias for nargs(1); simplifying the implementation significantly and moving behavior closer to the parser.

BREAKING CHANGE: requiresArg now has significantly different error output, matching nargs.
@bcoe bcoe requested a review from evocateur January 20, 2018 23:37
@@ -204,7 +204,7 @@ function Yargs (processArgs, cwd, parentRequire) {

self.requiresArg = function (keys) {
argsert('<array|string>', [keys], arguments.length)
populateParserHintArray('requiresArg', keys)
populateParserHintObject(self.nargs, false, 'narg', keys, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is calling self.nargs(keys, 1) too cute, here?

Both ways seem fine, the tradeoff being a duplicated call to populateParserHintObject vs a redundant argsert in the nested call...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evocateur it doesn't seem too cute; I like your idea of calling self.nargs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was envisioning it being the entire contents of the method, not in addition to the duplicate argsert+populate call.

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 this pull request may close these issues.

None yet

2 participants