Class: Diogenes::Cli::Evaluate

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

Class Method Summary collapse

Class Method Details

.run(argv:, out:, err:, **opts) ⇒ Object

: (argv: Array, out: IO, err: IO, **untyped) -> Integer



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/diogenes/cli/evaluate.rb', line 10

def self.run(argv:, out:, err:, **opts)
  options = {} #: Hash[Symbol, String]
  remaining = argv.dup
  OptionParser.new do |o|
    o.on("--answers ANSWERS") { |v| options[:answers] = v }
    o.on("--format FORMAT") { |v| options[:format] = v }
  end.parse!(remaining)

  description = remaining.join(" ").strip

  if description.empty?
    err.puts "Usage: diogenes evaluate \"<feature description>\" [--answers gate1=pass,...] [--format json]"
    return 1
  end

  if options[:answers]
    Evaluation::CiRunner.new(description:, answers: options[:answers], format: options[:format], out:, err:).run
  else
    Evaluation::Session.new(description:, out:, err:, **opts).run
  end
end