Class: Nicetest::Cli::Opts

Inherits:
Struct
  • Object
show all
Defined in:
lib/nicetest/cli.rb

Class Method Summary collapse

Class Method Details

.parse!(argv) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/nicetest/cli.rb', line 207

def parse!(argv)
  old_officious = OptionParser::Officious.dup
  OptionParser::Officious.clear

  options = new
  parser = OptionParser.new do |opts|
    opts.banner = ""
    opts.raise_unknown = false
    opts.on("--cd=DIR", "Change directory before running tests") do |dir|
      options[:cd] = dir
    end

    opts.on("-n", "--name=PATTERN", "Filter test names on pattern") do |pattern|
      options[:name] = pattern
    end
  end

  parser.parse!(argv)
  OptionParser::Officious.replace(old_officious)
  options
end