Class: Mutant::CLI Private
- Inherits:
-
Object
- Object
- Mutant::CLI
- Defined in:
- lib/mutant/cli.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Commandline parser / runner
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: OptionParser
Constant Summary collapse
- OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i[ add_environment_options add_mutation_options add_filter_options add_debug_options ].freeze
Class Method Summary collapse
-
.apply(world, config, arguments) ⇒ Either<OptionParser::ParseError, Config>
private
Parse arguments into config.
-
.run(world, default_config, arguments) ⇒ Boolean
private
Run cli with arguments.
Instance Method Summary collapse
-
#parse(arguments) ⇒ Config
private
Parse the command-line options.
Class Method Details
.apply(world, config, arguments) ⇒ Either<OptionParser::ParseError, Config>
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.
Parse arguments into config
ignore :reek:LongParameterList
59 60 61 62 63 |
# File 'lib/mutant/cli.rb', line 59 def self.apply(world, config, arguments) Either .wrap_error(OptionParser::ParseError) { new(world, config).parse(arguments) } .lmap(&:message) end |
.run(world, default_config, arguments) ⇒ Boolean
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
rubocop:disable Style/Semicolon
ignore :reek:LongParameterList
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mutant/cli.rb', line 38 def self.run(world, default_config, arguments) License .apply(world) .bind { Config.load_config_file(world, default_config) } .bind { |file_config| apply(world, file_config, arguments) } .bind { |cli_config| Bootstrap.apply(world, cli_config) } .bind(&Runner.method(:apply)) .from_right { |error| world.stderr.puts(error); return false } .success? end |
Instance Method Details
#parse(arguments) ⇒ Config
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.
Parse the command-line options
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/mutant/cli.rb', line 78 def parse(arguments) opts = OptionParser.new do |builder| builder. = 'usage: mutant [options] MATCH_EXPRESSION ...' OPTIONS.each do |name| __send__(name, builder) end end parse_match_expressions(opts.parse!(arguments.dup)) config end |