Skip to content

Conversation

@joshrotenberg
Copy link
Collaborator

Summary

Extracts all profile command handlers from main.rs into a dedicated commands/profile.rs module, following the established pattern of commands/api.rs and commands/files_key.rs.

Changes

New Module: commands/profile.rs

Created new module with 8 focused handler functions:

  • handle_list - List all profiles with table/JSON formatting
  • handle_path - Show config file path
  • handle_show - Show profile details
  • handle_set - Create/update profiles with keyring support
  • handle_remove - Remove profiles with confirmation
  • handle_default_enterprise - Set default enterprise profile
  • handle_default_cloud - Set default cloud profile
  • handle_validate - Validate configuration (added in UX improvements: Better error messages and command hints #259)

Updated Files

  • commands/mod.rs - Added pub mod profile;
  • main.rs - Updated to call commands::profile::handle_profile_command()
  • Removed unused Context import from main.rs

Impact

Before

main.rs: 1,589 lines
  - execute_profile_command: ~660 lines (42% of file)

After

main.rs: 929 lines (41.5% reduction)
commands/profile.rs: 719 lines

Benefits

  1. Maintainability: Profile logic now in dedicated, focused module
  2. Consistency: Follows pattern established by api.rs and files_key.rs
  3. Testability: Can add unit tests for individual handlers
  4. Separation of Concerns: main.rs focuses on CLI parsing and routing only
  5. Easier Navigation: Developers can find profile logic in one place

Testing

  • ✅ All 45 library tests passing
  • ✅ No clippy warnings
  • ✅ Code formatted with cargo fmt
  • ✅ No behavior changes - pure code organization

Functionality Verification

All profile commands continue to work:

  • redisctl profile list - Table and JSON output
  • redisctl profile path - Show config path
  • redisctl profile show <name> - Show profile details
  • redisctl profile set <name> - Create/update profiles
  • redisctl profile remove <name> - Remove with confirmation
  • redisctl profile default-enterprise <name>
  • redisctl profile default-cloud <name>
  • redisctl profile validate - Configuration validation

Code Quality

  • No clippy warnings (-D warnings)
  • Proper error handling maintained
  • Tracing/logging preserved
  • Secure credential storage support intact

Related

Closes #402

Part of ongoing code quality improvements to make the codebase more maintainable.

- Create commands/profile.rs with all profile command handlers
- Move 660 lines of profile logic out of main.rs
- Reduce main.rs from 1,589 lines to 929 lines (41.5% reduction)
- Split into focused handlers: list, path, show, set, remove, validate, default-enterprise, default-cloud
- Update commands/mod.rs to include profile module
- Remove unused Context import from main.rs
- All 45 tests passing
- No clippy warnings

Main.rs now focuses on CLI parsing, initialization, and command routing.

Closes #402
@joshrotenberg joshrotenberg merged commit f6f6ea9 into main Oct 14, 2025
16 checks passed
@joshrotenberg joshrotenberg deleted the refactor/extract-profile-commands-402 branch October 14, 2025 16:08
@joshrotenberg joshrotenberg mentioned this pull request Oct 14, 2025
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.

refactor: Extract profile command handlers from main.rs to dedicated module

2 participants