Class: Calrom::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/calrom/cli.rb

Class Method Summary collapse

Class Method Details

.call(argv) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/calrom/cli.rb', line 3

def self.call(argv)
  begin
    config_files = OptionParser.call(argv).configs

    config = OptionParser.call(
      rc_options(config_files.empty? ? nil : config_files) +
      argv
    )

    calendar = config.calendar
  rescue ::OptionParser::ParseError, InputError => e
    STDERR.puts e.message
    exit 1
  end

  I18n.locale = config.locale

  config.formatter.call calendar, config.date_range
end