Class: Mutant::CLI

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/cli.rb

Overview

Comandline parser

Constant Summary collapse

Error =

Error raised when CLI argv is invalid

Class.new(RuntimeError)
EXIT_FAILURE =
1
EXIT_SUCCESS =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments = []) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize objecct

Parameters:

  • (Array<String>)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mutant/cli.rb', line 41

def initialize(arguments = [])
  @builder = Matcher::Builder.new(Env::Boot.new(Reporter::CLI.new($stderr), Cache.new))
  @debug = @fail_fast = @zombie = false
  @expected_coverage = 100.0
  @integration = Integration::Null.new
  parse(arguments)
  @config  = Config.new(
    zombie:            @zombie,
    debug:             @debug,
    matcher:           @builder.matcher,
    integration:       @integration,
    fail_fast:         @fail_fast,
    reporter:          Reporter::CLI.new($stdout),
    expected_coverage: @expected_coverage
  )
end

Instance Attribute Details

#configConfig (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return config

Returns:



64
65
66
# File 'lib/mutant/cli.rb', line 64

def config
  @config
end

Class Method Details

.run(arguments) ⇒ Fixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run cli with arguments

Parameters:

  • arguments (Array<String>)

Returns:

  • (Fixnum)

    the exit status



24
25
26
27
28
29
30
31
# File 'lib/mutant/cli.rb', line 24

def self.run(arguments)
  config = new(arguments).config
  runner = Runner::Config.run(config)
  runner.success? ? EXIT_SUCCESS : EXIT_FAILURE
rescue Error => exception
  $stderr.puts(exception.message)
  EXIT_FAILURE
end