Skip to content

refactor(cloud): clean table output and modular structure#98

Closed
joshrotenberg wants to merge 10 commits intomainfrom
refactor/cloud-commands-table-output
Closed

refactor(cloud): clean table output and modular structure#98
joshrotenberg wants to merge 10 commits intomainfrom
refactor/cloud-commands-table-output

Conversation

@joshrotenberg
Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the cloud commands to provide cleaner, more readable output and better code organization.

Key Changes

🎨 Clean Table Output

  • Replaced comfy-table (Unicode borders) with tabled using blank style (GitHub CLI-like)
  • Added smart truncation for long fields in table views
  • Automatic pager support for long output (like GitHub CLI)

📐 Vertical Detail Views

Added get commands with vertical layout for detailed views:

  • cloud subscription get <id> - Full subscription details
  • cloud database get <id> - Complete database info
  • cloud user get <id> - User details with security settings
  • cloud account get - Account information

🏗️ Modular Structure

Refactored monolithic cloud.rs (1576 lines) into focused modules:

  • account.rs - Account commands
  • subscription.rs - Subscription commands
  • database.rs - Database commands
  • user.rs - User commands
  • utils.rs - Shared utilities and helpers

Before/After

Before (Unicode borders, wrapping issues):

╭─────────┬────────────────┬─────────────────────────┬────────────────┬─────────────────┬
│ ID      ┆ NAME           ┆ EMAIL                   ┆ ROLE           ┆ STATUS          ┆

After (Clean, GitHub-style):

ID        NAME                        STATUS   PLAN    MEMORY   DATABASES   REGION
2898175   database-MF4SPWPA-that...   active   /mo   250MB    1           us-east-1
2370381   cache-LYOVBEO5              active   /mo   250MB    1           us-east-1

Features

  • Smart truncation by default (full data via -o json or -o yaml)
  • Supports both fixed and flexible subscriptions transparently
  • Relative dates ("9 min ago" vs ISO timestamps)
  • Color-coded statuses
  • Full backward compatibility

Test Plan

  • All existing tests pass
  • Manual testing of all commands
  • Clippy clean
  • Formatted with rustfmt

joshrotenberg added a commit that referenced this pull request Sep 4, 2025
- Remove unmaintained atty dependency (RUSTSEC-2024-0375, RUSTSEC-2021-0145)
- Use std::io::IsTerminal (stable since Rust 1.70.0) instead
- Fixes CI security vulnerability check on PR #98
- Add first Layer 2 command with smart table formatting
- Support JMESPath queries that output human-friendly tables
- Color-coded status indicators (green/yellow/red)
- Relative date formatting ("2 hours ago" for recent items)
- Smart field extraction from nested JSON structures
- Support for --json and --yaml output formats
- Human-readable memory sizes (GB/MB)
- Region display as provider/region format

Example usage:
  redisctl cloud subscription list                    # Table output
  redisctl cloud subscription list --json             # JSON output
  redisctl cloud subscription list -q '[?status==\'active\']'  # Filtered table

This establishes the pattern for all future human-friendly commands.
- Handle wrapped API response with users array
- Extract actual field names (signUp, options.mfaEnabled)
- Color-coded role display (OWNER in blue, Admin in yellow)
- MFA status with green/red checkmarks
- Support for GitHub/SSO user types
- Dimmed "Never" for users who haven't logged in

Tested with actual Cloud API and working perfectly!
- Replace comfy-table with tabled using blank style (GitHub CLI-like)
- Add smart truncation for long fields in table views
- Implement vertical detail views for get commands (subscription, database, user, account)
- Add automatic pager support for long output
- Refactor monolithic cloud.rs (1576 lines) into modular structure:
  - account.rs: Account commands
  - subscription.rs: Subscription commands (list, get)
  - database.rs: Database commands (list, get)
  - user.rs: User commands (list, get)
  - utils.rs: Shared utilities and helpers
- Support both fixed and flexible subscriptions transparently
- Improve output formatting with relative dates and color coding
- Maintain full backward compatibility with existing commands
- Remove unmaintained atty dependency (RUSTSEC-2024-0375, RUSTSEC-2021-0145)
- Use std::io::IsTerminal (stable since Rust 1.70.0) instead
- Fixes CI security vulnerability check on PR #98
- Migrate deprecated 'commit' stage to 'pre-commit'
- Migrate deprecated 'push' stage to 'pre-push'
- Run pre-commit migrate-config to update configuration
- Update various dependencies including clap, config, and log
- All updates are semver-compatible patch/minor versions
- No breaking changes
- Replace let-chains (requires Rust 1.64+) with nested if-let statements
- Replace is_some_and() (requires Rust 1.70+) with map().unwrap_or(false)
- Add clippy allow attributes for resulting collapsible-if warnings
- Ensures CI passes with project's minimum supported Rust version
- Move pager dependency to target-specific dependencies for Unix only
- Add conditional compilation for pager imports and usage
- Fixes CI failures on Windows where pager crate uses Unix-specific APIs
@joshrotenberg joshrotenberg force-pushed the refactor/cloud-commands-table-output branch from 6637129 to 8f8c61a Compare September 4, 2025 04:23
- Move std::io::IsTerminal import behind cfg(unix) attribute
- Fixes unused import warning on Windows builds
- Complements the Unix-only pager dependency
- Map anyhow::Error to RedisCtlError::OutputError in all Cloud commands
- Add RedisCtlError import to cloud command modules
- Fixes compilation errors on all platforms
joshrotenberg added a commit that referenced this pull request Sep 4, 2025
- Add clean GitHub CLI-style table output using tabled library
- Refactor monolithic cloud.rs into focused modules:
  - account.rs for account commands
  - subscription.rs for subscription management
  - database.rs for database operations
  - user.rs for user management
  - utils.rs for shared utilities
- Add vertical detail views for get commands
- Implement automatic paging for long output (Unix only)
- Add smart truncation for table fields
- Support JSON/YAML output formats with -o flag
- Fix Windows compatibility (Unix-only pager, IsTerminal)
- Fix error handling for anyhow::Error conversions
- Add comprehensive test coverage

Replaces PR #98 with clean rebase on main
@joshrotenberg
Copy link
Copy Markdown
Collaborator Author

Closing in favor of #109 which has a clean rebase on main to avoid CI dependency issues. All changes have been preserved.

@joshrotenberg joshrotenberg deleted the refactor/cloud-commands-table-output branch September 4, 2025 15:16
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.

1 participant