Skip to content

Commit

Permalink
Add: Implement rich progress class for displaying plugin progress
Browse files Browse the repository at this point in the history
Extend the default rich progress class for using it with our own
terminal class and set the defaults for the UI.
  • Loading branch information
bjoernricks authored and y0urself committed Aug 2, 2022
1 parent 1d8de57 commit 1fee198
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autohooks/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

from pontos.terminal.rich import RichTerminal as Terminal
from pontos.terminal.terminal import Signs
from rich.progress import BarColumn
from rich.progress import Progress as RichProgress
from rich.progress import SpinnerColumn, TaskProgressColumn, TextColumn

__all__ = (
"Terminal",
"Progress",
"Signs",
"bold_info",
"error",
Expand Down Expand Up @@ -74,3 +78,18 @@ def _set_terminal(term: Optional[Terminal] = None) -> Terminal:
else:
__term = term
return __term


class Progress(RichProgress):
def __init__(self, terminal: Terminal) -> None:
super().__init__(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TaskProgressColumn(),
console=terminal._console,
transient=True,
)

def finish_task(self, task_id):
self.update(task_id, total=1, advance=1)

0 comments on commit 1fee198

Please sign in to comment.