Skip to content

refactor: consider splitting cli.rs into multiple modules #440

@joshrotenberg

Description

@joshrotenberg

Problem

crates/redisctl/src/cli.rs has grown to 3,032 lines, making it difficult to navigate and maintain.

wc -l crates/redisctl/src/cli.rs
3032 crates/redisctl/src/cli.rs

Current Structure

The file contains:

  • Top-level CLI struct and enums
  • Cloud command enums (Account, Subscription, Database, User, ACL, etc.)
  • Enterprise command enums (Cluster, Database, Node, etc.)
  • Connectivity command enums (VPC, PSC, TGW)
  • Fixed plan command enums
  • Workflow command enums
  • All command argument definitions

Proposed Refactoring

Option 1: Split by Deployment Type (Recommended)

crates/redisctl/src/cli/
├── mod.rs                    # Top-level CLI struct, Commands enum
├── cloud.rs                  # All CloudCommands and sub-enums
├── enterprise.rs             # All EnterpriseCommands and sub-enums
├── profile.rs                # Profile command enums
├── api.rs                    # Raw API command enums
└── shared.rs                 # Shared types (OutputFormat, etc.)

Option 2: Granular Split by Resource

crates/redisctl/src/cli/
├── mod.rs
├── cloud/
│   ├── mod.rs
│   ├── account.rs
│   ├── subscription.rs
│   ├── database.rs
│   ├── connectivity.rs
│   └── ...
└── enterprise/
    ├── mod.rs
    ├── cluster.rs
    ├── database.rs
    └── ...

Benefits

  1. Easier Navigation: Find command definitions more quickly
  2. Better Organization: Group related commands together
  3. Reduced Merge Conflicts: Changes isolated to specific modules
  4. Clearer Ownership: Each module has a clear purpose
  5. Easier to Review: Smaller files in PRs

Considerations

  • This is a pure refactoring - no functionality changes
  • All imports would need to be updated
  • Could be done incrementally (e.g., start with splitting out Cloud commands)
  • Pattern to follow: Similar to how commands/ is already organized

Recommendation

Start with Option 1 (split by deployment type) as it's simpler and mirrors the existing command structure. Can further refine later if needed.

Impact

  • Low risk: Pure code organization, no logic changes
  • Medium effort: ~1-2 hours to split and verify all imports work
  • High value: Much easier to maintain going forward

Note: This is a "good housekeeping" issue - not urgent, but will make future development easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions