Class: Anima::CLI
- Inherits:
-
Thor
- Object
- Thor
- Anima::CLI
- Defined in:
- lib/anima/cli.rb,
lib/anima/cli/mcp.rb,
lib/anima/cli/mcp/secrets.rb
Defined Under Namespace
Classes: Mcp
Constant Summary collapse
- VALID_ENVIRONMENTS =
%w[development test production].freeze
- DEFAULT_PORT =
42134- DEFAULT_HOST =
"localhost:#{DEFAULT_PORT}"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
13 14 15 |
# File 'lib/anima/cli.rb', line 13 def self.exit_on_failure? true end |
Instance Method Details
#install ⇒ Object
18 19 20 21 |
# File 'lib/anima/cli.rb', line 18 def install require_relative "installer" Installer.new.run end |
#start ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/anima/cli.rb', line 60 def start env = [:environment] || ENV.fetch("RAILS_ENV", "development") unless VALID_ENVIRONMENTS.include?(env) say "Invalid environment: #{env}. Must be one of: #{VALID_ENVIRONMENTS.join(", ")}", :red exit 1 end ENV["RAILS_ENV"] = env unless File.directory?(File.("~/.anima")) say "Anima is not installed. Run 'anima install' first.", :red exit 1 end gem_root = Anima.gem_root system(gem_root.join("bin/rails").to_s, "db:prepare", chdir: gem_root.to_s) || abort("db:prepare failed") exec("foreman", "start", "-f", gem_root.join("Procfile").to_s, "-p", DEFAULT_PORT.to_s, chdir: gem_root.to_s) end |
#tui ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/anima/cli.rb', line 81 def tui require "ratatui_ruby" require_relative "../tui/app" host = [:host] || DEFAULT_HOST say "Connecting to brain at #{host}...", :cyan cable_client = TUI::CableClient.new(host: host) cable_client.connect TUI::App.new(cable_client: cable_client).run end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/anima/cli.rb', line 25 def update unless [:migrate_only] say "Upgrading anima-core gem..." unless system("gem", "update", "anima-core") say "Gem update failed.", :red exit 1 end # Re-exec with the updated gem so migration uses the new template. exec(File.join(Gem.bindir, "anima"), "update", "--migrate-only") end say "Migrating configuration..." require_relative "config_migrator" result = Anima::ConfigMigrator.new.run case result.status when :not_found say "Config file not found. Run 'anima install' first.", :red exit 1 when :up_to_date say "Config is already up to date." when :updated result.additions.each do |addition| say " added [#{addition.section}] #{addition.key} = #{addition.value.inspect}" end say "Config updated. Changes take effect immediately — no restart needed." end end |