module Climatic::Script::Base

Public Class Methods

included(base) click to toggle source
# File lib/climatic/script/base.rb, line 36
def self.included(base)
  base.extend ClassMethods
end

Public Instance Methods

run() click to toggle source
# File lib/climatic/script/base.rb, line 17
def run
  # logging startup configuration
  Climatic.config.command_line_layer.cmd_line_args = ARGV.dup
  Climatic.logger.debug "Config layers ->\n#{Climatic.config.detailed_layers_info}"
  Climatic.logger.debug "Merged config -> #{Climatic.config[].to_yaml}"
  # Displaying (and exiting) command line help
  display_help_and_exit if Climatic.config[:help]
  check_config
  Climatic.logger.info 'Application is starting...'
  do_process
  Climatic.logger.info 'Application ended normally...'
rescue => e
  display_exit_error e
  exit_code = e.respond_to?(:exit_code) ? e.exit_code : 1
  exit exit_code
ensure
  Climatic.logger.info 'Exiting...'
end

Private Instance Methods

check_config() click to toggle source
# File lib/climatic/script/base.rb, line 55
def check_config
  # Check options validity in terms of dependencies
  cmd_line_mngr.command.valid? raise_error: true
  # Delegates to the processor the functional checks of the config
  cmd_line_mngr.processor.check_params cmd_line_mngr.cmd_line_args_for_command(cmd_line_mngr.command)
end
cmd_line_mngr() click to toggle source
# File lib/climatic/script/base.rb, line 51
def cmd_line_mngr
  Climatic.config.command_line_layer.command_line_manager
end
display_help_and_exit() click to toggle source
# File lib/climatic/script/base.rb, line 42
def display_help_and_exit
  puts Climatic.config.command_line_help
  exit 0
end
do_process() click to toggle source
# File lib/climatic/script/base.rb, line 47
def do_process
  cmd_line_mngr.processor.execute
end