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: split demand() into demandCommand()/demandOption() #740

Merged
merged 16 commits into from Dec 29, 2016
Merged

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented Dec 26, 2016

Getting @lrlna's wonderful work on splitting demand() into demandCommand()/demandOption() over the finish line.

Everything is %99 of the way there, just addressing some final nits from @maxrimue and myself -- excited to try to get yargs down to a few less open issue.

TODO:

fixes #504, #431 follow up with #618

@bcoe
Copy link
Member Author

bcoe commented Dec 27, 2016

@ljharb sorry this turned into a never ending yak shave! The demand() API was pretty all over the place, and it took quite a bit of refactoring to get things to where we wanted them.

Any ways, months overdue but I think this gets things to what you pushed us towards. Thanks @lrlna for the hard work 🎉

@ljharb
Copy link
Contributor

ljharb commented Dec 27, 2016

Thanks to everybody :-) I look forward to consuming it once it's released.

@bcoe bcoe requested review from nexdrew, lrlna and maxrimue and removed request for nexdrew December 27, 2016 07:11
Copy link
Member

@lrlna lrlna left a comment

Choose a reason for hiding this comment

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

Thanks for finishing this off @bcoe ✨ ; it looks really good!!

@bcoe bcoe merged commit 66573c8 into master Dec 29, 2016
@bcoe bcoe deleted the fix-demand-api branch December 29, 2016 06:23
@bcoe
Copy link
Member Author

bcoe commented Dec 29, 2016

@ljharb @maxrimue @lrlna this is queued up to go out with the next latest release of yargs. I would love your help testing since 6.6.0 is a big one:

npm cache clear; npm i yargs@next

@lrlna
Copy link
Member

lrlna commented Dec 29, 2016

@bcoe are you doing this one as a major though? Or with 6.6.0 ?

@bcoe
Copy link
Member Author

bcoe commented Dec 29, 2016

@lrlna since we opted to keep the demand() method for the time being, I see no reason to bump a major; however, I'm starting to picture what a 7.x release would look like. I would love to solve these problems specifically:

CC: @nexdrew, @maxrimue

@maxrimue
Copy link
Member

@bcoe I think that sounds like a good plan. What do you think when should we take action about the readme refactoring?

@bcoe
Copy link
Member Author

bcoe commented Dec 29, 2016

@maxrimue I approve of this message; I've noticed a lot of big JS projects have moved towards smaller READMEs with external doc sites.

@bcoe
Copy link
Member Author

bcoe commented Dec 29, 2016

@maxrimue want to start pulling together a v7 thread? I loved how you helped with release management last time.

@maxrimue
Copy link
Member

@bcoe on it

@kumar303
Copy link

kumar303 commented Jan 4, 2017

As of 6.6.0, demand() did slightly regress. The custom message is no longer displayed. That's ok though -- our tests failed, we read the readme, learned about the deprecation, and switched to the new methods :) Thanks for keeping a concise changelog.

@bcoe
Copy link
Member Author

bcoe commented Jan 4, 2017

@kumar303 mind sharing the syntax that had a regression for you, I'd like to patch this in the 6.x stream.

@kumar303
Copy link

kumar303 commented Jan 4, 2017

Sure, here is a script to reproduce it:

var yargs = require('yargs');
yargs
  .help('help')
  .demand(0, 0, 'This is a custom message to explain the error better')
  .strict()
  .argv;

In yargs@6.6.0:

$ node script.js nope
Options:
  --help  Show help                                                    [boolean]

Too many non-option arguments: got 1, maximum of 0

In yargs@6.5.0:

$ node script.js nope
Options:
  --help  Show help                                                    [boolean]

This is a custom message to explain the error better

@bcoe
Copy link
Member Author

bcoe commented Jan 5, 2017

@kumar303 thank you; I'll get a regression test written this evening.

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.

separate demand into demandOption and demandCommand
5 participants