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
Add invoke convenience method to Command #41
Conversation
@AliSoftware changelog and spec |
Not sure how to spec that. Any pointers? Thx
|
@subject.any_instance.expects(:run).once
@subject.invoke %w(arg1 arg2)
@subject.argv.should == ARGV.new %w(arg1 arg2) or something like that |
Ok for But |
Came up with a solution, but I don't find it very elegant 😒 |
# The arguments to initialize the command with | ||
# | ||
def self.invoke(*args) | ||
new(ARGV.new(args.flatten)).run |
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 should be calling validate!
before run.
Actually, what's wrong with Command::run? |
It exits on failure. |
So should we call |
It should validate, but it should not rescue. As these commands will usually be invoked from a running program, rescuing will be handled by the main |
Ok gotcha. |
Add invoke convenience method to Command
Implementation of #40 by @AliSoftware