File size: 1,057 Bytes
ad887b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Progress tracking for CLI operations."""
from contextlib import contextmanager
from typing import Iterator
from rich.console import Console

console = Console()

class ProgressTracker:
    """Track progress of file processing."""
    
    def __init__(self, description: str = "Processing..."):
        self.description = description
        self.status = None
        self.processed_files = 0
    
    @contextmanager
    def progress(self) -> Iterator[None]:
        """Context manager for tracking progress."""
        with console.status(f"[bold green]{self.description}") as status:
            self.status = status
            yield
            self.status = None
    
    def update(self, message: str) -> None:
        """Update progress status.
        
        Args:
            message: Current status message
        """
        if self.status:
            self.processed_files += 1
            self.status.update(
                f"[bold yellow]Processed {self.processed_files} files, "
                f"[bold green]{message}"
            )