Module: WeatherSage::CLI

Defined in:
lib/weather-sage/cli.rb,
lib/weather-sage/cli/env.rb,
lib/weather-sage/cli/commands/geocode.rb,
lib/weather-sage/cli/commands/stations.rb

Overview

Command-line interface for weather-sage.

Defined Under Namespace

Modules: Commands, Env, Forecast, Help

Class Method Summary collapse

Class Method Details

.run(app, args) ⇒ Object

Entry point for command-line interface.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/weather-sage/cli.rb', line 13

def self.run(app, args)
  require 'csv'
  require 'logger'
  require 'fileutils'

  args = ['help'] unless args.size > 0

  # wrap environment and create context
  env = Env::Env.new(ENV)
  ctx = Env::Context.new(env)

  # map first argument to command, then run it
  (Commands.const_get('%sCommand' % [
    args.shift.capitalize
  ]) || Commands::HelpCommand).run(ctx, app, args)
end