3
4
5
6
7
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
|
# File 'lib/calrom/cli.rb', line 3
def self.call(argv)
begin
config_files = OptionParser.call(argv).configs
config = EnvironmentReader.call
config = OptionParser.call(
rc_options(config_files.empty? ? nil : config_files) +
argv,
config
)
calendar = config.calendar
rescue OptionParser::Error, InputError => e
STDERR.puts e.message
exit 1
end
begin
I18n.locale = config.locale
rescue I18n::InvalidLocale
locales_help = I18n.available_locales.join(', ')
STDERR.puts "Locale '#{config.locale}' unsupported (available locales: #{locales_help})"
exit 1
end
unless config.verbose
HTTPI.log = false
end
begin
config.build_formatter.call calendar, config.date_range
rescue CR::Remote::UnexpectedResponseError => e
STDERR.puts "Remote calendar query failed: #{e.message}"
exit 1
rescue InputError => e
STDERR.puts e.message
exit 1
rescue Errno::EPIPE
end
end
|