File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1515from concurrent .futures import ThreadPoolExecutor , as_completed
1616from pathlib import Path
1717from typing import List
18-
18+ import time
19+ import shutil
1920from tuda_workspace_scripts .print import *
2021from tuda_workspace_scripts .workspace import get_workspace_root
2122
@@ -201,8 +202,25 @@ def update(**_) -> bool:
201202 # ----------------------- parallel phase ------------------------------- #
202203 total = len (repos )
203204
205+ _BAR_START = time .monotonic ()
206+
204207 def _progress (idx : int ):
205- print (f"\r Updating { total } repositories… { idx } /{ total } " , end = "" , flush = True )
208+ """Draw a simple progress bar that lives on one terminal line."""
209+ cols = shutil .get_terminal_size ((80 , 20 )).columns
210+ bar_len = max (10 , min (50 , cols - 30 )) # leave space for counters & percent
211+ filled = int (bar_len * idx / total )
212+ bar = (
213+ ("=" * filled + ">" + " " * (bar_len - filled - 1 ))
214+ if idx < total
215+ else "=" * bar_len
216+ )
217+ percent = (idx * 100 ) // total
218+ elapsed = time .monotonic () - _BAR_START
219+ print (
220+ f"\r [{ bar } ] { percent :3d} % { idx } /{ total } | { elapsed :4.0f} s" ,
221+ end = "" ,
222+ flush = True ,
223+ )
206224
207225 results : List [RepoResult ] = []
208226 done = 0
You can’t perform that action at this time.
0 commit comments