Class: EDango::Starter

Inherits:
Object show all
Defined in:
lib/edango/starter.rb

Constant Summary collapse

SPECS =
{:account_flag =>
['-a', '--account URL_REGEX,TICKET_LINK_REGEX,PASSKEY[,LOGIN:PASSWORD[,LOGIN_URL]]',
 'Adds account specifications used to obtain a ticket.'],
       :clear_flag =>
['-c', '--clear', 'Clear all account specifications from the configuration.'],
       :server_flag =>
['-s', '--server NAME:VALUE[,NAME:VALUE]', 'Specifies parameters for the "Sinatra" library.'],
       :proxy_flag =>
['-p', '--proxy HOST:PORT[:USER:PASSWORD]', 'Specifies proxy server parameters.'],
       :version_flag =>
['-v', '--version', 'Displays version information and exits.'],
       :help_flag =>
['-h', '--help', 'Displays this help message and exits.'],
       :quiet_flag =>
['-q', '--quiet', 'Starts in quiet mode.'],
       :verbose_flag =>
['-V', '--verbose', 'Starts in verbose mode (ignored in quiet mode).'],
       :debug_flag =>
['-d', '--debug', 'Starts in debug mode.']}

Instance Method Summary collapse

Constructor Details

#initializeStarter

Returns a new instance of Starter.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/edango/starter.rb', line 45

def initialize
  @environment = SERVICES[:environment]

  @options = @environment.options
  @options[:parameters] ||= []

  @modes = @environment.modes
  @tasks = @environment.tasks

  @parser = OptionParser.new()
end

Instance Method Details

#optionsObject



77
78
79
# File 'lib/edango/starter.rb', line 77

def options
  SPECS
end

#runObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/edango/starter.rb', line 57

def run
  if options_parsed?()
    begin
      if @modes[:verbose]
        @environment.show_message("#{FULL_NAME} has started", :log)
      end

      SERVICES[:executor].run()

      if @modes[:verbose]
        @environment.show_message("#{FULL_NAME} has finished all tasks", :log)
      end
    rescue Exception => e
      @environment.log_error(e, 'Command line interface failure')
    end
  end

  GLOBALS[:errors_number] || 0
end