Module: EasyAppHelper::Scripts::Common
- Included in:
- Master, SubCommandBase
- Defined in:
- lib/easy_app_helper/scripts/common.rb
Instance Method Summary collapse
Instance Method Details
#extra_parameters ⇒ Object
6 7 8 |
# File 'lib/easy_app_helper/scripts/common.rb', line 6 def extra_parameters EasyAppHelper.config.command_line_layer.extra_parameters end |
#pre_process(object = self) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/easy_app_helper/scripts/common.rb', line 10 def pre_process(object=self) safe_execution {} if object.respond_to? :add_script_options # logging startup configuration logger.debug "Config layers ->\n#{config.detailed_layers_info}" logger.debug "Merged config -> #{config[].to_yaml}" # Displaying (and exiting) command line help if config[:help] puts display_help exit 0 end object.check_config if object.respond_to? :check_config logger.info 'Application is starting...' end |
#safe_execution ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/easy_app_helper/scripts/common.rb', line 25 def safe_execution yield if block_given? rescue => e STDERR.puts "Program ended with message: '#{e.message}'." if config[:debug] logger.fatal "#{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}" else STDERR.puts ' Use --debug option for more detail (see --help).' end exit 1 end |