Skip to content

Commit

Permalink
Merge pull request #96 from cyberious/uniq_nodes
Browse files Browse the repository at this point in the history
Add a uniq function to nodes array to ensure we deduplicate list
  • Loading branch information
adreyer authored Oct 16, 2017
2 parents 103438c + 3a456bb commit 555b4ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bolt/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def print_help(mode)

def parse_nodes(nodes)
list = get_arg_input(nodes)
list.split(/[[:space:],]+/).reject(&:empty?)
list.split(/[[:space:],]+/).reject(&:empty?).uniq
end

def parse_params(params)
Expand Down
5 changes: 5 additions & 0 deletions spec/bolt/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
end
end

it "accepts multiple nodes but is uniq" do
cli = Bolt::CLI.new(%w[command run --nodes foo,bar,foo])
expect(cli.parse).to include(nodes: %w[foo bar])
end

it "generates an error message if no nodes given" do
cli = Bolt::CLI.new(%w[command run --nodes])
expect {
Expand Down

0 comments on commit 555b4ed

Please sign in to comment.