115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/cf/cli/production.rb', line 115
def list
set_target_uri(false)
set_api_key
CF.account_name = CF::Account.info.name
param = {}
current_page = 1
if options['line'].present?
line_title = options['line'].parameterize
param.merge!({:line_title => line_title})
if options['all']
param.merge!({:page => "all"})
current_page = 1
end
if page = options['page'].presence
param.merge!({:page => page})
current_page = page
end
else
if options['all']
param = {:page => "all"}
current_page = 1
end
if page = options['page'].presence
param.merge!({:page => page})
current_page = page
end
end
resp_runs = CF::Run.all(param)
if resp_runs.has_key?('error')
say("#{resp_runs['error']}", :red) and exit(1)
end
if resp_runs.has_key?("runs") && resp_runs['runs'].blank?
say("\nRun list is empty.\n", :yellow) and return
end
if resp_runs['total_pages']
say("\nShowing page #{current_page} of #{resp_runs['total_pages']} (Total runs: #{resp_runs['total_runs']})")
end
runs = resp_runs['runs'].presence
runs.sort! {|a, b| a['title'] <=> b['title'] }
runs_table = table do |t|
t.headings = ["Run Title", 'URL']
runs.each do |run|
run = Hashie::Mash.new(run)
t << [run.title, "http://#{CF.account_name}.cloudfactory.com/runs/#{CF.account_name}/#{run.title}"]
end
end
say("\n")
if runs_table.rows.present?
say(runs_table)
else
say("No production run for line #{line_title}", :yellow)
end
end
|