Skip to content

Improve CLI User Experience #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

codegen-sh[bot]
Copy link
Contributor

@codegen-sh codegen-sh bot commented Jun 4, 2025

🎨 CLI UX Enhancement

This PR significantly improves the grain-chain CLI user experience with better error messages, progress indicators, colored output, and enhanced functionality.

✨ Key Features

🎯 Enhanced CLI Utilities (grainchain/cli/utils.py)

  • Colored Output: Success (green), error (red), warning (yellow), info (blue) styling
  • Progress Indicators: Spinner and progress bar for long-running operations
  • Table Formatting: Clean, readable tables for benchmark results
  • Duration Formatting: Human-readable time display (ms, s, m)
  • Dependency Checking: Automated validation of required tools
  • Confirmation Prompts: Safety checks for destructive operations

🚨 Smart Error Handling (grainchain/cli/exceptions.py)

  • Custom Exception Classes: Specialized errors with actionable suggestions
  • DependencyError: Missing tools with installation instructions
  • ProviderError: Sandbox provider issues with troubleshooting tips
  • BenchmarkError: Test failures with debugging guidance
  • ConfigurationError: Setup problems with fix suggestions

πŸ”§ Enhanced Main CLI (grainchain/cli/main.py)

  • Global Verbose Mode: --verbose flag for detailed debugging output
  • Improved Commands: All commands now have progress tracking and better error handling
  • Safety Features: Confirmation prompts for destructive operations
  • Better Messaging: Clear, actionable error messages with suggestions

πŸ“Š Enhanced Benchmark CLI (grainchain/cli/benchmark.py)

  • Progress Tracking: Real-time progress for each test execution
  • Formatted Results: Clean tables with success/failure indicators
  • Summary Statistics: Total duration, success rate, average execution time
  • Provider-Specific Errors: Tailored error messages for different providers
  • Verbose Mode Support: Detailed logging for debugging

πŸ§ͺ Testing

  • Comprehensive test suite for all new utilities
  • Mock-based testing for CLI interactions
  • Coverage for error handling scenarios
  • Tests for table formatting and duration display

🎯 Addresses Issue Requirements

  • βœ… Progress indicators for benchmark operations
  • βœ… Improved error messages with actionable suggestions
  • βœ… Colored output for better readability
  • βœ… Helpful tips in error scenarios
  • βœ… Verbose mode for debugging
  • βœ… Improved benchmark result formatting
  • βœ… Confirmation prompts for destructive operations

πŸ” Example Usage

# Verbose mode for debugging
grainchain --verbose benchmark

# Enhanced error messages
grainchain benchmark --provider nonexistent
# ❌ Invalid provider: 'nonexistent'
# πŸ’‘ Available providers: local|e2b|daytona

# Progress indicators and formatted results
grainchain benchmark --provider local
# πŸ”„ Running benchmarks...
# βœ… File Operations (1.23s)
# βœ… Snapshot Lifecycle (0.85s)
# πŸ“Š Results table with statistics

πŸ“ Files Modified

  • grainchain/cli/main.py - Enhanced main CLI interface
  • grainchain/cli/benchmark.py - Improved benchmark implementation
  • grainchain/cli/utils.py - New CLI utilities (created)
  • grainchain/cli/exceptions.py - Custom exception classes (created)
  • tests/cli/ - Comprehensive test suite (created)

πŸŽ‰ Impact

This enhancement significantly improves the developer experience by:

  • Reducing confusion with clear, actionable error messages
  • Providing visual feedback during long operations
  • Making output more readable and professional
  • Helping users troubleshoot common issues independently
  • Adding safety features to prevent accidental damage

πŸ’» View my work β€’ About Codegen

- Add CLI utilities with colored output, progress indicators, and error handling
- Enhance main CLI commands with verbose mode and better error messages
- Implement enhanced benchmark CLI with progress tracking and formatted results
- Add custom exception classes with actionable error suggestions
- Create comprehensive test suite for new CLI features
- Add confirmation prompts and safety features

Key improvements:
- Progress indicators for long-running operations
- Colored output for better readability (success/error/warning/info)
- Verbose mode for debugging with detailed logging
- Better error messages with actionable suggestions
- Formatted benchmark results with tables and statistics
- Enhanced error handling for common scenarios (Docker, API keys, providers)
- Confirmation prompts for destructive operations
- Comprehensive test coverage for new functionality
@jayhack jayhack marked this pull request as ready for review June 4, 2025 03:21
@jayhack jayhack merged commit d5c4b47 into main Jun 4, 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.

1 participant