Sha256: c6413101887477da37529bca0b6afbac5dab6c2a2be6ee6e169f433a4a994ba8

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'optparse'

class Autotestforphp
  class CLI
    def self.execute(stdout, arguments=['--run'])
      arguments = ['--run'] unless arguments.count > 0 # defaults to run

      OptionParser.new do |opts|
        opts.banner = <<-BANNER.gsub(/^          /,'')
          Usage: #{File.basename($0)} [options]

          Options are:
BANNER

        opts.separator("")

        opts.on('-i', '--install',
          'Install AutotestForPHP') do
          Autotestforphp.install
          stdout.puts 'Autotest for PHP was installed successfully'
        end

        opts.on('-r', '--run',
          'Run AutotestForPHP (default)') do
          config_file = File.expand_path('./autotestforphp/config.autotest')
          load config_file if File.exist?(config_file)

          unless defined?(FOLDERS_TO_WATCH)
            folders = ["./src/**/*", "./test/**/*", "./app/**/*", "./lib/**/*"]
          else
            folders = FOLDERS_TO_WATCH
          end
          Autotestforphp.run(folders)
        end

        opts.on("-h", "--help",
                "Show this help message.") { stdout.puts opts; exit }

        opts.parse!(arguments)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fgrehm-autotestforphp-0.0.1 lib/autotestforphp/cli.rb