Don't clobber pre-existing options when adding new ones
This commit is contained in:
parent
40a9cde119
commit
76924d98b3
|
@ -27,7 +27,8 @@ class Pry
|
|||
|
||||
# Define or get the command's options
|
||||
def command_options(arg=nil)
|
||||
@command_options = arg if arg
|
||||
@command_options ||= {}
|
||||
@command_options.merge!(arg) if arg
|
||||
@command_options
|
||||
end
|
||||
# backward compatibility
|
||||
|
|
|
@ -223,6 +223,16 @@ describe "Pry::Command" do
|
|||
|
||||
mock_command(cmd, %w(--four 4 four))
|
||||
end
|
||||
|
||||
it 'should allow overriding options after definition' do
|
||||
cmd = @set.command_class /number-(one|two)/, "Lieutenants of the Golgafrinchan Captain", :shellwords => false do
|
||||
|
||||
command_options :listing => 'number-one'
|
||||
end
|
||||
|
||||
cmd.command_options[:shellwords].should == false
|
||||
cmd.command_options[:listing].should == 'number-one'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'tokenize' do
|
||||
|
|
Loading…
Reference in New Issue