Sha256: cb37e079ff63d8eac85292d9612199a534f893215e7ea5c7ab39dbf4046ff75b

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'optparse'

class Autotestforphp
  class CLI
    def self.execute(stdout, arguments=['--run'])
      arguments = ['--run'] unless arguments.size > 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
autotestforphp-0.0.3 lib/autotestforphp/cli.rb