lib/mutant/cli.rb in mutant-0.7.8 vs lib/mutant/cli.rb in mutant-0.7.9

- old
+ new

@@ -1,7 +1,5 @@ -require 'optparse' - module Mutant # Commandline parser class CLI include Adamantium::Flat, Equalizer.new(:config), Procto.call(:config) @@ -66,17 +64,17 @@ # def parse(arguments) opts = OptionParser.new do |builder| builder.banner = 'usage: mutant [options] MATCH_EXPRESSION ...' %w[add_environment_options add_mutation_options add_filter_options add_debug_options].each do |name| - send(name, builder) + __send__(name, builder) end end parse_match_expressions(opts.parse!(arguments)) rescue OptionParser::ParseError => error - raise(Error, error.message, error.backtrace) + raise(Error, error) end # Parse matchers # # @param [Array<String>] expressions @@ -126,12 +124,11 @@ # @return [undefined] # # @api private # def setup_integration(name) - require "mutant/integration/#{name}" - update(integration: Integration.lookup(name)) + update(integration: Integration.setup(name)) rescue LoadError raise Error, "Could not load integration #{name.inspect} (you may want to try installing the gem mutant-#{name})" end # Add mutation options @@ -141,14 +138,20 @@ # @return [undefined] # # @api private # def add_mutation_options(opts) - opts.separator(EMPTY_STRING) + opts.separator(nil) opts.separator('Options:') - opts.on('--score COVERAGE', 'Fail unless COVERAGE is not reached exactly') do |coverage| + opts.on( + '--expected-coverage COVERAGE', + 'Fail unless COVERAGE is not reached exactly, parsed via Rational()' + ) do |coverage| + update(expected_coverage: Rational(coverage)) + end + opts.on('--score COVERAGE', 'Fail unless COVERAGE is not reached exactly [deprecated]') do |coverage| update(expected_coverage: Rational(coverage, 100)) end opts.on('--use STRATEGY', 'Use STRATEGY for killing mutations', &method(:setup_integration)) end @@ -180,10 +183,10 @@ def add_debug_options(opts) opts.on('--fail-fast', 'Fail fast') do update(fail_fast: true) end opts.on('--version', 'Print mutants version') do - puts("mutant-#{Mutant::VERSION}") + puts("mutant-#{VERSION}") Kernel.exit(EXIT_SUCCESS) end opts.on('-d', '--debug', 'Enable debugging output') do update(debug: true) end