Class: RubynCode::CLI::Commands::Provider

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/provider.rb

Constant Summary collapse

USAGE_LINES =
[
  'Usage:',
  '  /provider list                            List configured providers',
  '  /provider add <name> <base_url> [opts]    Add a provider',
  '  /provider set-key <name> <key>            Store an API key',
  '',
  'Options for add:',
  '  --key <api_key>              API key (stored securely in tokens.yml)',
  '  --format <openai|anthropic>  API format (default: openai)',
  '  --models <m1,m2,...>          Comma-separated model names',
  '',
  'Example:',
  '  /provider add groq https://api.groq.com/openai/v1 --key gsk-xxx --models llama-3.3-70b'
].freeze
FLAG_KEYS =
{ '--format' => :api_format, '--env-key' => :env_key, '--key' => :key }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, all_names, hidden?

Class Method Details

.command_nameObject



7
# File 'lib/rubyn_code/cli/commands/provider.rb', line 7

def self.command_name = '/provider'

.descriptionObject



8
# File 'lib/rubyn_code/cli/commands/provider.rb', line 8

def self.description = 'Manage providers (/provider add|list|set-key)'

Instance Method Details

#execute(args, ctx) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/rubyn_code/cli/commands/provider.rb', line 27

def execute(args, ctx)
  return show_usage(ctx) if args.empty?

  case args.first
  when 'add' then add_provider(args[1..], ctx)
  when 'list' then list_providers(ctx)
  when 'set-key' then set_key(args[1..], ctx)
  else show_usage(ctx)
  end
end