Class: Miniswen::CLI
- Inherits:
-
Object
- Object
- Miniswen::CLI
- Defined in:
- lib/miniswen/cli.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Reporter
Instance Attribute Summary collapse
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/miniswen/cli.rb', line 88 def initialize @instruction = nil @model = ENV.fetch("MINISWEN_MODEL", nil) @options = {} @verbose = false @quiet = false @results_path = nil @atif_path = nil @refresh_registry = false @skip_registry_refresh = false end |
Instance Attribute Details
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction.
86 87 88 |
# File 'lib/miniswen/cli.rb', line 86 def instruction @instruction end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
86 87 88 |
# File 'lib/miniswen/cli.rb', line 86 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
86 87 88 |
# File 'lib/miniswen/cli.rb', line 86 def @options end |
Instance Method Details
#run ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/miniswen/cli.rb', line 100 def run parse_args! # Require the core library after parsing options, # so env flags kick in require "miniswen" refresh_registry_and_exit if @refresh_registry Miniswen.refresh_registry! unless @skip_registry_refresh require "miniswen/local" reporter = @quiet ? nil : Reporter.new(verbose: @verbose) agent = Agent.new(model:, reporter:, environment: Local.new, **) begin result = agent.run(instruction) rescue StandardError => e write_results(agent.partial_result((e))) raise end write_results(result) if result.success? reporter&.print_summary(result) else reporter&.print_failure(result) Kernel.exit(1) end end |