Commit 242c3efa authored by Youhei SASAKI's avatar Youhei SASAKI

New upstream version 4.4.5

parent 69f4f191
=== 4.4.5 / 2018-05-22
* Make internal command state less mutable. (@doriantaylor)
=== 4.4.4 / 2018-01-18
* Fix deprecated constant warnings on Ruby 2.5. (@mattbrictson)
......
......@@ -171,9 +171,13 @@ module Commander
# Call the commands when_called block with _args_.
def call(args = [])
object = @when_called.shift
meth = @when_called.shift || :call
object, meth = @when_called[0, 2]
meth ||= :call
options = proxy_option_struct
# empty the proxy option stack before the next invocation
proxy_options.clear
case object
when Proc then object.call(args, options)
when Class then meth != :call ? object.new.send(meth, args, options) : object.new(args, options)
......
module Commander
VERSION = '4.4.4'.freeze
VERSION = '4.4.5'.freeze
end
......@@ -74,6 +74,16 @@ describe Commander::Command do
it 'should raise an error when no handler is present' do
expect { @command.when_called }.to raise_error(ArgumentError)
end
it 'should be able to be run more than once' do
expect(@command.run('once')).to eql('test once')
expect(@command.run('twice')).to eql('test twice')
end
it 'should empty @proxy_options after running' do
expect(@command.run('--verbose')).to eql('test ')
expect(@command.proxy_options.empty?).to be true
end
end
describe 'should populate options with' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment