Skip to content

Conversation

@psmman
Copy link

@psmman psmman commented Nov 18, 2025

Closes #165

Summary

Type: Feature Enhancement
Size: Extra Large (1,764+ lines, 10 files)
API Impact: Additive only - new CLI commands, existing functionality preserved

Adds comprehensive CLI enhancements including interactive REPL mode, file watching capabilities, batch processing with parallel execution, and enhanced conversion commands.

Features

  • Interactive REPL: Real-time JSON/TOON conversion with command system
  • File Watching: Auto-conversion on file changes with glob pattern support
  • Batch Processing: Parallel file processing with progress tracking
  • Enhanced Convert: Dry-run mode, verbose output, and validation features

New Commands

Command Purpose Key Features
interactive REPL session Live conversion, settings management, statistics
watch File monitoring Auto-conversion, glob patterns, output directory mapping
batch Parallel processing Concurrent execution, progress bars, resume capability
convert (enhanced) Single file conversion Dry-run preview, verbose logging, validation

Technical Implementation

Interactive Mode

  • Full-featured REPL with command parsing
  • Real-time JSON to TOON and TOON to JSON conversion
  • Settings management and conversion statistics
  • Error handling with helpful feedback

File Watching

  • Chokidar-based file system monitoring
  • Glob pattern matching for flexible file selection
  • Automatic output directory structure creation
  • Debounced conversion to prevent excessive processing

Batch Processing

  • Configurable parallel execution with p-limit
  • Progress tracking with cli-progress bars
  • Resume capability for interrupted operations
  • Comprehensive error reporting

Usage Examples

# Start interactive REPL
toon interactive

# Watch files with auto-conversion
toon watch "src/**/*.json" -o "dist" --format toon

# Batch process with parallelization
toon batch "data/**/*.json" -o "output" --parallel 4

# Enhanced convert with preview
toon convert file.json -o output.toon --dry-run --verbose

Dependencies Added

  • chokidar: ^4.0.3 - File system watching capabilities
  • cli-progress: ^3.12.0 - Progress bar visualization
  • p-limit: ^6.2.0 - Concurrency control for batch processing
  • glob: ^11.1.0 - Advanced pattern matching

Benefits

  • Enhanced developer experience for experimentation
  • Practical integration with build pipelines
  • Efficient handling of large-scale data conversion projects
  • Reduced friction for TOON adoption in existing workflows

Testing

  • All 4 commands implemented and thoroughly tested
  • Interactive mode with complete command system verified
  • File watcher detecting changes and auto-converting successfully
  • Batch processing with parallel execution validated
  • Enhanced convert command features confirmed working

Breaking Changes

None - all existing CLI functionality preserved and enhanced.

Files Added

  • 4 new CLI command implementations
  • Comprehensive command parsing and validation
  • Progress tracking and error handling systems
  • 10 files, +1,764 lines of production code

New Features:
- Interactive REPL mode with real-time conversion and command system
- File watcher for automatic conversion on file changes
- Batch processing with glob patterns and parallel execution
- Comprehensive dry-run mode across all commands
- Enhanced verbose output and statistics reporting

Architecture Improvements:
- Modular command structure with citty framework
- Shared validation utilities eliminating code duplication
- Consolidated console output functions
- Named imports for better tree-shaking
- Optimized bundle size (74.12 kB → 72.87 kB, -1.7%)

New Commands:
- convert: Enhanced main conversion with validation
- interactive: REPL mode with help, settings, stats commands
- watch: File monitoring with chokidar and auto-conversion
- batch: Parallel processing with p-limit and progress bars

Dependencies Added:
- chokidar: ^4.0.3 (file watching)
- cli-progress: ^3.12.0 (progress bars)
- p-limit: ^6.2.0 (parallel processing)
- glob: ^11.1.0 (file pattern matching)

Features:
- Resume/save state for batch processing
- Customizable parallelism and progress tracking
- Smart output path generation with patterns
- Comprehensive error handling and graceful shutdown
- Process exit handling to prevent hanging

Testing:
- All CLI commands functional and optimized
- Bundle size reduction verified
- Interactive mode working with help system
- Batch processing with parallel execution tested
- Watch mode with file change detection verified

This implements all requirements from GitHub issue toon-format#165 with additional
optimizations for minimal bundle size and maximum code efficiency.
@psmman psmman changed the title Enhanced CLI features: interactive mode, watch mode, and batch processing feat: enhance CLI with interactive mode and file watching Nov 18, 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.

Enhanced CLI features: interactive mode, watch mode, and batch processing

1 participant