Class: RubynCode::CLI::FirstRun
- Inherits:
-
Object
- Object
- RubynCode::CLI::FirstRun
- 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
-
.needed?(config_path: Config::Defaults::CONFIG_FILE) ⇒ Boolean
Returns true if first-run setup should be triggered.
-
.skipped?(skip_flag: false) ⇒ Boolean
Returns true if the user opted to skip setup.
Instance Method Summary collapse
-
#initialize(config_path: Config::Defaults::CONFIG_FILE, prompt: nil) ⇒ FirstRun
constructor
A new instance of FirstRun.
- #run ⇒ Object
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.
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.
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
#run ⇒ Object
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 |