8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/pact_broker/client/cli/version_selector_options_parser.rb', line 8
def self.call words
selectors = []
previous_option = nil
split_equals(words).each do | word |
case word
when "--pacticipant", "-a"
selectors << {}
when "--ignore"
selectors << { ignore: true }
when "--latest", "-l"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:latest] = true
when "--main-branch"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:main_branch] = true
selectors.last[:latest] = true
when /^\-/
nil
else
case previous_option
when "--pacticipant", "-a"
selectors.last[:pacticipant] = word
when "--ignore"
selectors.last[:pacticipant] = word
when "--version", "-e"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:version] = word
when "--latest", "-l"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:tag] = word
when "--branch"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:branch] = word
selectors.last[:latest] = true
when "--main-branch"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:main_branch] = true
selectors.last[:latest] = true
when "--all"
selectors << { pacticipant: nil } if selectors.empty?
selectors.last[:tag] = word
end
end
previous_option = word if word.start_with?("-")
end
selectors
end
|