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 |
# 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 @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
99 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 |
# File 'lib/miniswen/cli.rb', line 99 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, **) result = agent.run(instruction) File.write(@results_path, JSON.generate(result.to_h)) if @results_path if result.success? reporter&.print_summary(result) else reporter&.print_failure(result) Kernel.exit(1) end end |