class Snapdragon::CommandLineParser

Public Class Methods

parse(args) click to toggle source
# File lib/snapdragon/command_line_parser.rb, line 7
def self.parse(args)
  options = OpenStruct.new
  options.format = "console"
  options.color = true
  options.pattern = "spec/**/*_spec.js"
  options.jasmine_ver = "2"

  opts = OptionParser.new do |opts|
    opts.banner = "Usage: snapdragon [options] [files or directories]"
    opts.on('-v', '--version', "Show the current version of this gem") do
      puts "#{Snapdragon::VERSION}"; exit
    end
    opts.on('-h', '--help', "show usage") do
      puts opts; exit
    end
    opts.on('-f', '--format [FORMAT]', "set output format") do |format|
      options.format = format
    end
    opts.on('-N', "--nocolor", '--nocolour', 'Enable color in the output.') do
      options.color = false
    end
    opts.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.js").') do |pattern|
      options.pattern = pattern
    end
    opts.on('-J1', '--jasminev1', 'Use Jasmine v1.3.1 instead of the default v2.x.') do
      options.jasmine_ver = "1"
    end
  end
  opts.parse!(args)
  options
end