Module: DeployInfo::CLI

Extended by:
CLI
Included in:
CLI
Defined in:
lib/deploy-info/cli.rb

Overview

> Deploy-Info Launcher

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Instance Method Details

#run(argv = ARGV) ⇒ Object

> Launch the Application



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/deploy-info/cli.rb', line 72

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

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

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

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

  # => Apply Configuration
  DeployInfo::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.state_file          = config[:state_file]
    cfg.environment         = config[:environment].to_sym
    cfg.github_oauth_token  = config[:github_oauth_token]
    cfg.nr_api_key          = config[:nr_api_key]
  end

  # => Launch the API
  DeployInfo::API.run!
end