Sha256: 513b5ea1e19ea33453f98e8642e3d4e747c14e2e7a4d64de14e051c4cd6fd67f

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'optparse'
require 'ostruct'
require_relative './version'

module Snapdragon
  class CommandLineParser
    def self.parse(args)
      options = OpenStruct.new
      options.format = "console" 
      options.color = true
      options.pattern = "spec/**/*_spec.js"

      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('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output.') do |o|
          options.color = o
        end
        opts.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.js").') do |pattern|
          options.pattern = pattern
        end
      end
      opts.parse!(args)
      options
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
snapdragon-1.0.0 lib/snapdragon/command_line_parser.rb
snapdragon-0.2.0 lib/snapdragon/command_line_parser.rb