Sha256: a79198b12ded8701e2b8454c2fa7ef4e00ef88100c1104ab5d557cf4102e9e29

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'argument_parser'
require 'project_home_finder'

module MavenHelperScript

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

    def run(args)
      finder = MavenHelperScript::ProjectHomeFinder.new

      file = File.expand_path(".")
      projectFolder = finder.findProjectDirectory(file)

      parser = MavenHelperScript::ArgumentParser.new(projectFolder)

      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."

    rescue MavenHelperScript::MissingProjectFolderException => e
      puts "Unable to locate project folder in this directory or any above it."
      puts "\nA valid project folder must contain:"
      puts "\tAn m.yml file."
      puts "\tA pom.xml file.\n"
    end

  end

end



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maven-helper-script-0.2.1 lib/script_runner.rb
maven-helper-script-0.2.0 lib/script_runner.rb