Skip to content

Commit

Permalink
feat: suppport equals sign in can-i-deploy pacticipant selector param…
Browse files Browse the repository at this point in the history
…eters

Fixes: #55
  • Loading branch information
bethesque committed Feb 12, 2020
1 parent da54dc1 commit b5d89bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/pact_broker/client/cli/version_selector_options_parser.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# frozen_string_literal: true

module PactBroker
module Client
module CLI
class VersionSelectorOptionsParser

def self.call words
selectors = []
previous_option = nil
words.each do | word |
split_equals(words).each do | word |
case word
when "--pacticipant", "-a"
selectors << {}
Expand Down Expand Up @@ -33,6 +36,16 @@ def self.call words
end
selectors
end

def self.split_equals(words)
words.flat_map do |word|
if word.start_with?("-") && word.include?("=")
word.split('=', 2)
else
word
end
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ module CLI
],[
["--pacticipant", "Foo", "--all", "prod", "--pacticipant", "Bar"],
[{ pacticipant: "Foo", tag: "prod"}, { pacticipant: "Bar" } ]
],[
["--pacticipant=Foo", "--version=1.2.3"],
[{ pacticipant: "Foo", version: "1.2.3" } ]
],[
["--pacticipant=Foo=Bar", "--version", "1.2.3"],
[{ pacticipant: "Foo=Bar", version: "1.2.3" } ]
],[
["--pacticipant", "Foo=Bar", "--version", "1.2.3"],
[{ pacticipant: "Foo=Bar", version: "1.2.3" } ]
]
]

Expand Down

0 comments on commit b5d89bc

Please sign in to comment.