Skip to content

Commit

Permalink
Bug 953767 - Arguments that are arrays should set the options to an a…
Browse files Browse the repository at this point in the history
…rray
  • Loading branch information
smarterclayton committed Apr 19, 2013
1 parent 4195d9a commit c6456d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rhc/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def self.fill_arguments(cmd, options, args_metadata, options_metadata, args)
raise ArgumentError, "Missing required argument '#{arg[:name]}'." unless arg[:optional]
break if available.empty?
else
value = Array(value) if arg[:arg_type] == :list
slots[i] = value
options.__hash__[option] = value if option
end
Expand Down
3 changes: 2 additions & 1 deletion spec/rhc/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test; 1; end
alias_action :exe, :deprecated => true
def execute(testarg); 1; end

argument :args, "Test arg list", ['--tests'], :arg_type => :list
argument :args, "Test arg list", ['--tests ARG'], :arg_type => :list
summary "Test command execute-list"
def execute_list(args); 1; end

Expand Down Expand Up @@ -185,6 +185,7 @@ def context_var
it { expects_running('static-execute-list', '--trace').should call(:execute_list).on(instance).with([]) }
it { expects_running('static-execute-list', '1', '2', '3').should call(:execute_list).on(instance).with(['1', '2', '3']) }
it { expects_running('static-execute-list', '1', '2', '3').should call(:execute_list).on(instance).with(['1', '2', '3']) }
it('should make the option an array') { expects_running('static-execute-list', '--tests', '1').should call(:execute_list).on(instance).with(['1']) }
it('should make the option available') { command_for('static-execute-list', '1', '2', '3').send(:options).tests.should == ['1','2','3'] }
end

Expand Down

0 comments on commit c6456d7

Please sign in to comment.