Class: TestLauncher::CLI::InputParser

Inherits:
Object
  • Object
show all
Defined in:
lib/test_launcher/cli/input_parser.rb

Constant Summary collapse

ParseError =
Class.new(RuntimeError)
"Find tests and run them by trying to match an individual test or the name of a test file(s).\n\nSee full README: https://github.com/petekinnecom/test_launcher\n\nUsage: `test_launcher \"search string\" [--all]`\n\nVERSION: \#{TestLauncher::VERSION}\n\n"

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ InputParser

Returns a new instance of InputParser.



20
21
22
23
24
25
26
27
28
29
# File 'lib/test_launcher/cli/input_parser.rb', line 20

def initialize(args)
  @query = args
  @options = {}
  option_parser.parse!(args)
rescue OptionParser::ParseError
  puts "Invalid arguments"
  puts "----"
  puts option_parser
  exit
end

Instance Method Details

#optionsObject



42
43
44
# File 'lib/test_launcher/cli/input_parser.rb', line 42

def options
  @options
end

#queryObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/test_launcher/cli/input_parser.rb', line 31

def query
  if @query.size == 0
    puts option_parser
    exit
  elsif @query.size > 1
    puts "Concatenating args to single string. (see https://github.com/petekinnecom/test_launcher)"
  end

  @query.join(" ")
end