Skip to content

Conversation

@baxen
Copy link
Collaborator

@baxen baxen commented Dec 25, 2025

Summary

Refactors the handle_configure function in crates/goose-cli/src/commands/configure.rs from 203 lines down to 9 lines by extracting logical sections into focused helper functions.

Changes

Split the monolithic handle_configure function into smaller, focused helpers:

  • handle_first_time_setup (58 lines): Handles welcome flow and setup method selection (openrouter/tetrate/manual)
  • handle_manual_provider_setup (28 lines): Handles manual provider configuration result and error handling
  • print_manual_config_error (48 lines): Handles ConfigError display with platform-specific keyring messages
  • print_keyring_error (platform-specific, cfg-gated): Platform-specific keyring error messages for macOS/Windows/Linux
  • handle_existing_config (53 lines): Handles configuration updates for existing setups

The main handle_configure function is now just 9 lines, delegating to appropriate helpers based on whether config exists.

Testing

  • cargo build -p goose-cli
  • cargo test -p goose-cli ✅ (112 tests pass)
  • cargo fmt
  • cargo clippy -p goose-cli ✅ (no errors or warnings in configure.rs)

Related

Part of TSK-696: Simplify clippy baseline system

Split the 203-line handle_configure function into smaller, focused helpers:
- handle_first_time_setup: Handles welcome flow and setup method selection
- handle_manual_provider_setup: Handles manual provider configuration result
- print_manual_config_error: Handles ConfigError display with platform-specific keyring messages
- print_keyring_error: Platform-specific keyring error messages (cfg-gated)
- handle_existing_config: Handles configuration updates for existing setups

The main handle_configure function is now 9 lines, delegating to appropriate
helpers based on whether config exists. All helper functions are under 60 lines.
Copilot AI review requested due to automatic review settings December 25, 2025 03:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the monolithic handle_configure function by extracting its logic into focused helper functions, reducing it from 203 lines to 9 lines without changing functionality.

Key changes:

  • Main function now delegates to handle_first_time_setup or handle_existing_config based on config existence
  • Error handling extracted into print_manual_config_error and platform-specific print_keyring_error functions
  • Manual provider setup flow extracted into handle_manual_provider_setup

@baxen baxen marked this pull request as draft December 25, 2025 03:29
@baxen baxen marked this pull request as ready for review December 25, 2025 04:13
@baxen baxen changed the title TSK-707: Refactor handle_configure to reduce line count chore: refactor handle_configure to reduce line count Dec 25, 2025
@baxen baxen mentioned this pull request Dec 26, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants