Class: CommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/command_runner.rb

Instance Method Summary collapse

Constructor Details

#initializeCommandRunner

Returns a new instance of CommandRunner.



201
202
203
204
205
# File 'lib/command_runner.rb', line 201

def initialize
  @options = {}
  @options[:include_paths] = ""
  @options[:library_paths] = ""
end

Instance Method Details

#runObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/command_runner.rb', line 207

def run

  return unless parse_args
  
  if ARGV.length == 0
    puts HELP
    return
  end

  cmd = ARGV[0]

  if @options[:help]
    Help.new.run(cmd)
    return
  end

  case cmd
    when "help"; Help.new.run(ARGV[1])
    when "install";
      # When installation is interrupted on administrator account password input, terminal
      # is set to echo the character
      begin
        Installer.new.install(@options)
      ensure
        system('stty echo')
      end
    when "uninstall"; Installer.new.uninstall
    when "clear"; WebroarCommand.new.clear
    when "start", "stop", "restart" ; WebroarCommand.new.operation(ARGV, cmd)
    when "add" ; WebroarCommand.new.add(@options, ARGV)
    when "remove" ; WebroarCommand.new.remove(ARGV)
    when "test"; Installer.new.test(@options)
  else
    puts "ERROR:  Invalid command: #{cmd}.  See 'webroar help commands'."
  end
end