Closed imrehg closed 10 years ago
@imrehg thanks a lot for this - and sorry i didn't see it until now. would you mind resolving conflicts and i will go ahead and merge?
Sure thing!
If I fix it up, is it okay, that I update the rest of the command line as well? This patch was kind of the first step to see whether you are interested, and using the command line I found a few more cases which could be fixed up.
Will do a series of commits on a single branch, and you can see if they fit you.
Sounds great. Looking forward to reviewing. Thanks for your interest!
Did some pretty heavy refactoring since the last movement on this. Will reopen if you still have some improvements.
Move the "-e|--email" option to the "login" command since no other command requires it.
A tricky part is to get the option values out of the commander library. Apparently top level ("program" options) are accessed through the program's name (here e.g. "bitpay.optionname"), while command-specific options are passed to the .action function (in this patch e.g. "env.optionname"). This means one has to be mindful whether an option is global (accessible all through the "program") or just within the option and retrieve the option value accordingly.
Also changed "[email]" to "", meaning that the email value is a
required parameter of "-e|--email" option (ie. "bitpay login -e" is not
a valid command when using "" in the settings, while it would be
valid using the previous "[email]" form. This affects the other options
as well, but that's beyond the scope of this patch.
Unfortunately as I see commander does not allow (yet) for making flags required (i.e. to make it invalid to call "bitpay login" without "-e"), so internal checks are still needed. See more at the upstream issue tracker of visionmedia/commander.js/issues/44
Patch is also related to #25.
Signed-off-by: Gergely Imreh imrehg@gmail.com