Class: EasyAppHelper::Scripts::Master

Inherits:
Object
  • Object
show all
Includes:
EasyAppHelper, Common, Completion
Defined in:
lib/easy_app_helper/scripts/master.rb

Constant Summary

Constants included from EasyAppHelper

ManagedConfig, ManagedLogger, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Completion

#completion_script_changed?, #deploy_zsh_completion_script, #install_or_update_completion

Methods included from Common

#extra_parameters, #pre_process, #safe_execution

Methods included from EasyAppHelper

#config, #logger, #puts_and_logs, #safely_exec_code, #safely_exec_command

Constructor Details

#initialize(app_name, app_version, app_description, config_file_base_name = nil) ⇒ Master

Returns a new instance of Master.



12
13
14
15
16
17
18
# File 'lib/easy_app_helper/scripts/master.rb', line 12

def initialize(app_name, app_version, app_description, config_file_base_name=nil)
  @script_name = File.basename $0
  config.config_file_base_name = config_file_base_name.nil? ? script_name : config_file_base_name
  config.describes_application app_name: app_name,
                               app_version: app_version,
                               app_description: app_description
end

Instance Attribute Details

#script_nameObject (readonly)

Returns the value of attribute script_name.



10
11
12
# File 'lib/easy_app_helper/scripts/master.rb', line 10

def script_name
  @script_name
end

Instance Method Details

#display_helpObject



49
50
51
# File 'lib/easy_app_helper/scripts/master.rb', line 49

def display_help
  config.command_line_help
end

#do_processObject



53
54
55
# File 'lib/easy_app_helper/scripts/master.rb', line 53

def do_process
  raise 'Please implement do_process in your action !'
end

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/easy_app_helper/scripts/master.rb', line 20

def run
  safe_execution do
    if sub_command_mode?
      if ARGV.length == 1
        %w(--help -h --version).each do |option|
          if ARGV.include? option
            if option == '--version'
              puts DeploymentManager::VERSION
            else
              puts display_help
            end
            exit 0
          end
        end
      end
      if ARGV.empty?
        puts display_help
        exit 0
      end
      delegate_to_sub_command
    else
      pre_process
      do_process
    end
    logger.info 'Application terminates successfully...'
    exit 0
  end
end