Class: MightyTest::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(file_system: FileSystem.new, env: ENV, option_parser: OptionParser.new, runner: MinitestRunner.new) ⇒ CLI

Returns a new instance of CLI.



3
4
5
6
7
8
# File 'lib/mighty_test/cli.rb', line 3

def initialize(file_system: FileSystem.new, env: ENV, option_parser: OptionParser.new, runner: MinitestRunner.new)
  @file_system = file_system
  @env = env.to_h
  @option_parser = option_parser
  @runner = runner
end

Instance Method Details

#run(argv: ARGV) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mighty_test/cli.rb', line 10

def run(argv: ARGV)
  @path_args, @extra_args, @options = option_parser.parse(argv)

  if options[:help]
    print_help
  elsif options[:version]
    puts VERSION
  elsif options[:watch]
    watch
  elsif path_args.grep(/.:\d+$/).any?
    
  else
    run_tests_by_path
  end
rescue Exception => e # rubocop:disable Lint/RescueException
  handle_exception(e)
end