Module: CloudImagesRunDeck::CLI

Extended by:
CLI
Included in:
CLI
Defined in:
lib/cloudimages-rundeck/cli.rb

Overview

> CloudImages-RunDeck Launcher

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Instance Method Details

#run(argv = ARGV) ⇒ Object

> Launch the Application



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cloudimages-rundeck/cli.rb', line 62

def run(argv = ARGV)
  # => Parse CLI Configuration
  cli = Options.new
  cli.parse_options(argv)

  # => Parse JSON Config File (If Specified and Exists)
  json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file)

  # => Grab the Default Values
  default = Config.options

  # => Merge Configuration (CLI Wins)
  config = [default, json_config, cli.config].compact.reduce(:merge)

  # => Apply Configuration
  Config.setup do |cfg|
    cfg.config_file         = config[:config_file]
    cfg.cache_timeout       = config[:cache_timeout].to_i
    cfg.bind                = config[:bind]
    cfg.port                = config[:port]
    cfg.environment         = config[:environment].to_sym
    cfg.do_api_key          = config[:do_api_key]
  end

  # => Launch the API
  API.run!
end