Class: Agentic::CLI::Config
- Inherits:
-
Thor
- Object
- Thor
- Agentic::CLI::Config
- Defined in:
- lib/agentic/cli/config.rb
Overview
CLI commands for managing configuration
Constant Summary collapse
- CONFIG_FILE_NAME =
".agentic.yml"
- USER_CONFIG_PATH =
File.join(Dir.home, CONFIG_FILE_NAME)
- PROJECT_CONFIG_PATH =
File.join(Dir.pwd, CONFIG_FILE_NAME)
Instance Method Summary collapse
Instance Method Details
#get(key) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/agentic/cli/config.rb', line 33 def get(key) config = active_config value = config[key] if value puts value else puts "Key '#{key}' not found in configuration" exit 1 end end |
#init ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/agentic/cli/config.rb', line 77 def init path = [:global] ? USER_CONFIG_PATH : PROJECT_CONFIG_PATH if File.exist?(path) puts "Configuration already exists at #{path}" return end config = { "model" => "gpt-4o-mini" # Add other default configuration options here } save_config(path, config) puts "Configuration initialized at #{path}" end |
#list ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/agentic/cli/config.rb', line 15 def list user_config = load_config(USER_CONFIG_PATH) project_config = load_config(PROJECT_CONFIG_PATH) puts "User configuration (#{USER_CONFIG_PATH}):" print_config(user_config) puts "\nProject configuration (#{PROJECT_CONFIG_PATH}):" print_config(project_config) puts "\nActive configuration:" print_config(active_config) puts "\nEnvironment variables:" puts " OPENAI_ACCESS_TOKEN: #{ENV["OPENAI_ACCESS_TOKEN"] ? "[SET]" : "[NOT SET]"}" end |
#set(key_value) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/agentic/cli/config.rb', line 48 def set(key_value) key, value = key_value.split("=", 2) unless value puts "Error: Invalid format. Use KEY=VALUE" exit 1 end path = [:global] ? USER_CONFIG_PATH : PROJECT_CONFIG_PATH config = load_config(path) || {} # Convert string values to appropriate types value = case value.downcase when "true" then true when "false" then false when /^\d+$/ then value.to_i when /^\d+\.\d+$/ then value.to_f else value end config[key] = value save_config(path, config) puts "Configuration updated successfully." end |