Class: OpenGeoDb::CLI

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/open_geo_db/cli.rb

Constant Summary collapse

DEFAULT_CONFIG =
{"open_geo_db" =>
{"database" => "open_geo_db", "username" => "root", "password" => ""}}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.action_option(name, description) ⇒ Object



12
13
14
15
# File 'lib/open_geo_db/cli.rb', line 12

def self.action_option(name, description)
  option(name, :short => "-#{name.to_s[0].chr} config", :long => "--#{name} CONFIG",
      :description => description)
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/open_geo_db/cli.rb', line 24

def run
  parse_options
  action = config.keys.first
  @config_file = config.values.first
  if action == :generate
    generate
  else
    puts("Using config file #{@config_file}")
    database = OpenGeoDb::Database.new(YAML.load_file(@config_file)["open_geo_db"])
    database.execute(action)
  end
end