Class: RubynCode::CLI::FirstRun

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyn_code/cli/first_run.rb

Overview

Guided first-run setup wizard.

Runs when no ~/.rubyn-code/config.yml exists (first launch). Walks the user through provider selection, API key configuration, and default budget setup.

Skippable via –skip-setup flag or RUBYN_SKIP_SETUP=1 env var.

Constant Summary collapse

PROVIDERS =
{
  'Anthropic (recommended)' => 'anthropic',
  'OpenAI' => 'openai',
  'Other (configure later)' => 'other'
}.freeze
DEFAULT_BUDGET =
5.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path: Config::Defaults::CONFIG_FILE, prompt: nil) ⇒ FirstRun

Returns a new instance of FirstRun.



25
26
27
28
# File 'lib/rubyn_code/cli/first_run.rb', line 25

def initialize(config_path: Config::Defaults::CONFIG_FILE, prompt: nil)
  @config_path = config_path
  @tty_prompt = prompt
end

Class Method Details

.needed?(config_path: Config::Defaults::CONFIG_FILE) ⇒ Boolean

Returns true if first-run setup should be triggered.

Returns:

  • (Boolean)


31
32
33
# File 'lib/rubyn_code/cli/first_run.rb', line 31

def self.needed?(config_path: Config::Defaults::CONFIG_FILE)
  !File.exist?(config_path)
end

.skipped?(skip_flag: false) ⇒ Boolean

Returns true if the user opted to skip setup.

Returns:

  • (Boolean)


36
37
38
# File 'lib/rubyn_code/cli/first_run.rb', line 36

def self.skipped?(skip_flag: false)
  skip_flag || ENV['RUBYN_SKIP_SETUP'] == '1'
end

Instance Method Details

#runObject



40
41
42
43
44
45
46
47
# File 'lib/rubyn_code/cli/first_run.rb', line 40

def run
  display_welcome
  provider = ask_provider
  configure_api_key(provider)
  budget = ask_budget
  write_config(provider, budget)
  display_summary
end