Sha256: fb09d8cda37b300356ecf4818bec8a441036991aaa9e2e54e6638b7e15a4e94e

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'argument_parser'
require 'project_home_finder'

module MavenHelperScript

  class ScriptRunner
    LINE = "\n-------------------------------------------------------------------------------\n\n"

    def initialize()
      finder = MavenHelperScript::ProjectHomeFinder.new
      @projectFolder = finder.findProjectDirectory(File.expand_path("."))
      @parser = MavenHelperScript::ArgumentParser.new(@projectFolder)
    end

    def run(args)
      commands = @parser.parse(args)

      successful = true
      i = 0

      while successful && i < commands.length
        command = commands[i]
        puts LINE
        puts "#{command}"
        puts LINE

        successful = system command
        i += 1
      end

      if successful
        puts LINE
        puts "Successfully executed the following commands: "
        commands.each do |command|
          puts " - " << command
        end
        puts LINE
      else
        puts LINE
        puts "Failed executing command: " << command
        puts LINE
      end
    rescue MavenHelperScript::InvalidCommandException => e
      puts "Unable to process command: " << e.failedCommand
      puts "\nFound Commands: "
      e.commands.each do |key, value|
        puts "\t" << key << " : " << value
      end
      puts "\nUse valid combinations of the commands above."
    end

  end

end



Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
maven-helper-script-0.1.3 lib/script_runner.rb