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
|
# File 'lib/gaapi/main.rb', line 8
def call
begin
return false if (options = process_options).nil?
puts "options: #{options.inspect}" if options[:debug]
query = Query.new((options[:query_file] || $stdin).read,
options[:view_id],
options[:access_token],
options[:start_date],
options[:end_date])
puts "query: #{query.inspect}" if options[:debug]
rescue StandardError => e
$stderr.puts e.message
return false
end
return true if options[:dry_run]
result = query.execute
puts "result: #{result.inspect}" if options[:debug]
unless result.success?
puts result.body
return false
end
case options[:output_format]
when :csv
puts result.csv
else
puts result.pp
end
true
end
|