This example demonstrates the comprehensive progress bar system in WebFiori CLI, showcasing various styles, formats, and real-time progress tracking capabilities.
- Creating and customizing progress bars with different styles
- Real-time progress tracking and updates
- Progress bar formats and display options
- Performance monitoring with rate calculations
- Integration with long-running operations
- Error handling and validation
ProgressDemoCommand.php- Comprehensive progress bar demonstrationsmain.php- Application entry pointREADME.md- This documentation
# Show all progress bar styles
php main.php progress-demo
# Show help
php main.php help --command=progress-demo# All styles demonstration
php main.php progress-demo --style=all --items=20 --delay=50
# Individual styles
php main.php progress-demo --style=default --items=10 --delay=100
php main.php progress-demo --style=ascii --items=50 --delay=20
php main.php progress-demo --style=dots --items=15 --delay=80
php main.php progress-demo --style=arrow --items=25 --delay=40
php main.php progress-demo --style=custom --items=12 --delay=150# Different format templates
php main.php progress-demo --style=dots --format=eta --items=15
php main.php progress-demo --style=arrow --format=rate --items=25
php main.php progress-demo --style=custom --format=verbose --items=12# Quick demo (minimum items)
php main.php progress-demo --style=default --items=10 --delay=50
# Longer demo (more items)
php main.php progress-demo --style=ascii --items=100 --delay=10
# Slow demo (longer delays)
php main.php progress-demo --style=dots --items=20 --delay=200default- Unicode block characters (█░) - Modern terminalsascii- ASCII characters (=->) - Maximum compatibilitydots- Circular dots (●○) - Clean appearancearrow- Directional arrows (▶▷) - Visual flow indicationcustom- Emoji style (🟩⬜) - Modern and colorfulall- Demonstrate all styles sequentially
--items- Number of items to process (10-1000, default: 50)--delay- Delay between items in milliseconds (default: 100)--format- Progress bar format template (eta, rate, verbose)
- Items must be between 10 and 1000
- Delay can be any positive integer
- Invalid values show helpful error messages
🎯 Progress Bar Demonstration
=============================
📊 Demo Configuration:
• Style: All styles
• Items: 20
• Delay: 50ms per item
• Estimated time: 1 seconds
🎨 Default Style (Unicode)
Processing with default style... [████████████████████████████████████████] 100.0% (20/20)
Complete! [████████████████████████████████████████] 100.0% (20/20)
🎨 ASCII Style (Compatible)
Processing with ascii style... [========================================] 100.0% (20/20)
Complete! [========================================] 100.0% (20/20)
🎨 Dots Style (Circular)
Processing with dots style... [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 100.0% (20/20)
Complete! [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 100.0% (20/20)
🎨 Arrow Style (Directional)
Processing with arrow style... [▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶] 100.0% (20/20)
Complete! [▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶] 100.0% (20/20)
🎨 Custom Style (Emoji)
Processing with emoji style... 🚀 {message} [🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩] 100.0% | ⚡ 20/s | ⏱️ 00:00
🎉 Emoji processing complete! 🚀 {message} [🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩] 100.0% | ⚡ 20/s | ⏱️ 00:00
✨ Progress bar demonstration completed!
Processing with default style... [████████████████████░░░░░░░░░░░░░░░░░░░░] 50.0% (5/10)
Processing with default style... [████████████████████████████████████████] 100.0% (10/10)
Complete! [████████████████████████████████████████] 100.0% (10/10)
Processing with ascii style... [====================--------------------] 50.0% (25/50)
Processing with ascii style... [========================================] 100.0% (50/50)
Complete! [========================================] 100.0% (50/50)
Processing with dots style... [●●●●●●●●●●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○] 40.0% (6/15) ETA: 00:00
Processing with dots style... [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 100.0% (15/15) ETA: 00:00
Complete! [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 100.0% (15/15) ETA: 00:00
Processing with arrow style... [▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷▷] 40.0% (10/25) 25/s
Processing with arrow style... [▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶] 100.0% (25/25) 25/s
Complete! [▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶] 100.0% (25/25) 25/s
Processing with emoji style... 🚀 {message} [🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜] 50.0% | ⚡ 6.6/s | ⏱️ 00:00
Processing with emoji style... 🚀 {message} [🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩] 100.0% | ⚡ 6.6/s | ⏱️ 00:00
🎉 Emoji processing complete! 🚀 {message} [🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩] 100.0% | ⚡ 6.6/s | ⏱️ 00:00
# Invalid item count (too low)
php main.php progress-demo --items=5
Error: Number of items must be between 10 and 1000
# Invalid item count (too high)
php main.php progress-demo --items=1001
Error: Number of items must be between 10 and 1000
php main.php progress-demo --style=all --items=20 --delay=50
# Shows all 5 styles in sequence with consistent parameters# Fast processing
php main.php progress-demo --style=ascii --items=50 --delay=20
# Medium processing
php main.php progress-demo --style=default --items=25 --delay=100
# Slow processing
php main.php progress-demo --style=custom --items=12 --delay=150# ETA format
php main.php progress-demo --style=dots --format=eta --items=15
# Rate format
php main.php progress-demo --style=arrow --format=rate --items=25
# Verbose format
php main.php progress-demo --style=custom --format=verbose --items=12# Minimum items
php main.php progress-demo --style=default --items=10 --delay=50
# Maximum items (test with caution - takes time)
php main.php progress-demo --style=ascii --items=1000 --delay=1
# Boundary validation
php main.php progress-demo --items=9 # Error: too low
php main.php progress-demo --items=1001 # Error: too high# Unicode vs ASCII compatibility
php main.php progress-demo --style=default --items=20 --delay=50
php main.php progress-demo --style=ascii --items=20 --delay=50
# Visual styles comparison
php main.php progress-demo --style=dots --items=20 --delay=50
php main.php progress-demo --style=arrow --items=20 --delay=50
php main.php progress-demo --style=custom --items=20 --delay=50- Live Progress: Updates show in real-time as work progresses
- Percentage Display: Current completion percentage
- Item Counters: Current/total item counts
- Rate Calculation: Items processed per second
- ETA Estimation: Estimated time to completion
- Unicode Blocks: Modern terminals with full block characters
- ASCII Compatible: Works on all terminal types
- Dot Indicators: Clean circular progress indicators
- Arrow Flow: Directional progress indication
- Emoji Style: Modern colorful progress with emojis
- Basic Format:
[bar] percentage (current/total) - ETA Format: Includes estimated time remaining
- Rate Format: Shows processing speed
- Verbose Format: All metrics with emojis and timing
- Processing Rate: Items per second calculation
- Time Tracking: Elapsed and estimated time
- Progress Percentage: Accurate completion percentage
- Item Counting: Current and total item tracking
ProgressDemoCommand: Main demonstration commandProgressBarFormat: Format template definitionsProgressBar: Core progress bar functionalityArgumentOption: Command argument configuration
demonstrateStyle(): Individual style demonstrationscreateProgressBar(): Progress bar creation and setupsimulateWork(): Work simulation with delaysvalidateParameters(): Input validation and error handling
- Style selection and character definitions
- Format template customization
- Timing and delay controls
- Item count validation and limits
- Clear visual progress indication
- Consistent formatting across styles
- Helpful error messages for invalid input
- Estimated completion times
- Efficient real-time updates
- Minimal CPU overhead during updates
- Accurate rate calculations
- Responsive progress tracking
- ASCII fallback for older terminals
- Unicode support for modern terminals
- Cross-platform character support
- Terminal width adaptation
- Input parameter validation
- Helpful error messages
- Boundary checking (10-1000 items)
- Type validation for arguments
- 04-output-formatting - ANSI colors and formatting
- 06-table-display - Data presentation techniques
- 08-file-processing - File operations with progress
- 10-multi-command-app - Complete CLI applications
- 01-basic-hello-world - Basic command structure
- 04-output-formatting - Colors and formatting
- 06-table-display - Structured data display
- 05-interactive-commands - Interactive workflows with progress
- 08-file-processing - File operations with progress tracking
- 09-database-ops - Database operations with progress indicators
- 03-user-input - Multi-step processes with progress
- 10-multi-command-app - Full applications with progress feedback
- 02-arguments-and-options - Commands with progress reporting
- 12-command-scaffolding - Generate commands with progress bars