Class: Mutant::CLI

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/cli.rb,
lib/mutant/cli/builder.rb,
lib/mutant/cli/classifier.rb,
lib/mutant/cli/classifier/method.rb,
lib/mutant/cli/classifier/namespace.rb

Overview

Comandline parser

Defined Under Namespace

Classes: Builder, Classifier

Constant Summary collapse

Error =

Error raised when CLI argv is invalid

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

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>)


43
44
45
46
47
48
49
50
# File 'lib/mutant/cli.rb', line 43

def initialize(arguments = [])
  @filters, @matchers = [], []
  @debug = @fail_fast = @zombie = false
  @cache = Mutant::Cache.new
  @strategy_builder = nil
  parse(arguments)
  config # trigger lazyness now
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



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

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

Instance Method Details

#configConfig

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:



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mutant/cli.rb', line 58

def config
  Config.new(
    cache:             @cache,
    zombie:            @zombie,
    debug:             @debug,
    matcher:           matcher,
    subject_predicate: @subject_predicate.output,
    strategy:          @strategy.output,
    fail_fast:         @fail_fast,
    reporter:          reporter
  )
end