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
|
# File 'lib/collins/cli/find.rb', line 145
def run!
raise "Options not yet parsed with #parse!" unless @parsed
raise "Options not yet validated with #validate!" unless @validated
if options[:mode] == :help
puts parser
else
page = 0
assets, res = [], []
begin
loop do
break if !options[:limit].nil? and assets.length >= options[:limit]
res = collins.find(query_opts.merge({:page => page}))
break if res.empty?
assets = assets.concat res
page += 1
end
rescue => e
raise "Error querying collins: #{e.message}"
end
unless options[:limit].nil?
format_assets(assets.first(options[:limit]), options)
else
format_assets(assets, options)
end
end
true
end
|