Class: Rubino::Commands::Handlers::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/commands/handlers/config.rb

Overview

The ‘/config` in-chat read/set surface, extracted from Commands::Executor (batch B) — over the SAME effective config (file merged over defaults) the `rubino config` CLI verbs use (#187), so checking `memory.backend` no longer means quitting the REPL. Rendering is shared with the CLI (CLI::ConfigCommand.render_get / .render_show), so secret-named keys are masked identically on both surfaces.

/config                  → config file path + usage hint
/config show             → the full merged config, secrets masked
/config path             → the config file path
/config <key>            → get (dot-notation; `get <key>` also works)
/config <key> <value>    → set: the same Config::Writer write-through
                           /reasoning uses (`set <key> <value>` too)

Instance Method Summary collapse

Constructor Details

#initialize(ui:) ⇒ Config

Returns a new instance of Config.



20
21
22
# File 'lib/rubino/commands/handlers/config.rb', line 20

def initialize(ui:)
  @ui = ui
end

Instance Method Details

#handle_config(arguments) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubino/commands/handlers/config.rb', line 24

def handle_config(arguments)
  tokens = arguments.to_s.strip.split(/\s+/)
  case tokens.first
  when nil    then show_config_summary
  when "show" then CLI::ConfigCommand.render_show(ui: @ui)
  when "path" then @ui.info(Rubino::Config::Loader.new.config_path)
  when "get"  then config_get(tokens[1])
  when "set"  then config_set(tokens[1], tokens[2..])
  else
    tokens.length == 1 ? config_get(tokens.first) : config_set(tokens.first, tokens[1..])
  end
end