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
Document Command
class in readme
#790
Comments
We do need to get something into the README about the "new" pattern, thanks for raising. I don't think we will deprecate the old way as such, but it should be the my-program-is-so-simple-globals-are-ok way of working. |
I have added the new pattern in a large update to README in #953 |
Awesome! LGTM |
Updated README with section right at start showing use of Command class |
I've noticed that by using the documented
const program = require('command')
syntax you're actually polluting a globalCommand
object. This can be shared by other components resulting in weird issues (like nicojs/node-link-parent-bin#4 (comment))After inspecting the source code, i see that a
Command
class is exported! Kudo's to you sir! I'll use this from now on. It also helps quite a bit with testability (injecting a mock object forCommand
at test time). Let's promote this way of working a bit by documenting it in the readmeMy idea is to update the readme and use
const Command = require('commander').Command; const program = new Command();
everywhere. I would like to place a remark to let people know that they could also useconst program = require('commander');
but that it is not preferred and explain why it is not.If you agree, I'm willing to create the PR.
I would personally like it if the
const program = require('commander');
-way-of-working would become deprecated and removed in a major release. What are your thoughts on that?The text was updated successfully, but these errors were encountered: