Skip to content

Commit 5a201d0

Browse files
committed
feat: amelioration du spinner BCASL avec mises a jour dynamiques
- Mise a jour de CliBcaslHost pour passer l'objet Status de Rich. - Permet la mise a jour dynamique du texte du spinner pendant l'execution des plugins BCASL. - Assure une feedback visuel 'vivant' meme en mode non-verbose.
1 parent 80cfdca commit 5a201d0

1 file changed

Lines changed: 36 additions & 18 deletions

File tree

Ui/Cli/helpers.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -481,25 +481,34 @@ def run_bcasl_before_compile_sync(workspace: Path, verbose: bool = False) -> boo
481481

482482
from .output import error, info, log, success, get_console
483483

484+
console = get_console()
485+
status = None
486+
if not verbose and console:
487+
status = console.status("[cyan]Verification BCASL...[/cyan]", spinner="dots")
488+
status.start()
489+
484490
class CliBcaslHost:
485-
def __init__(self, ws_dir: Path):
491+
def __init__(self, ws_dir: Path, status_obj):
486492
self.workspace_dir = str(ws_dir)
493+
self.status_obj = status_obj
487494

488495
class Logger:
496+
def __init__(self, host_ptr):
497+
self.host_ptr = host_ptr
498+
489499
def append(self, msg: str):
490500
if verbose:
491501
# Strip trailing newline as our log() adds one
492502
log("BCASL", msg.rstrip())
503+
elif self.host_ptr.status_obj:
504+
clean = msg.strip()
505+
if clean and not clean.startswith("["):
506+
if len(clean) < 100:
507+
self.host_ptr.status_obj.update(f"[cyan]BCASL: {clean}[/cyan]")
493508

494-
self.log = Logger()
509+
self.log = Logger(self)
495510

496-
host = CliBcaslHost(workspace)
497-
498-
console = get_console()
499-
status = None
500-
if not verbose and console:
501-
status = console.status("[cyan]Verification BCASL...[/cyan]", spinner="dots")
502-
status.start()
511+
host = CliBcaslHost(workspace, status)
503512

504513
if verbose:
505514
info("Running BCASL pre-compile checks...")
@@ -558,24 +567,33 @@ def run_bcasl_headless(args: list[str], verbose: bool = False) -> int:
558567
workspace = candidate.resolve()
559568
break
560569

570+
console = get_console()
571+
status = None
572+
if not verbose and console:
573+
status = console.status("[cyan]Verification BCASL (headless)...[/cyan]", spinner="dots")
574+
status.start()
575+
561576
class CliBcaslHost:
562-
def __init__(self, ws_dir: Path):
577+
def __init__(self, ws_dir: Path, status_obj):
563578
self.workspace_dir = str(ws_dir)
579+
self.status_obj = status_obj
564580

565581
class Logger:
582+
def __init__(self, host_ptr):
583+
self.host_ptr = host_ptr
584+
566585
def append(self, msg: str):
567586
if verbose:
568587
log("BCASL", msg.rstrip())
588+
elif self.host_ptr.status_obj:
589+
clean = msg.strip()
590+
if clean and not clean.startswith("["):
591+
if len(clean) < 100:
592+
self.host_ptr.status_obj.update(f"[cyan]BCASL: {clean}[/cyan]")
569593

570-
self.log = Logger()
594+
self.log = Logger(self)
571595

572-
host = CliBcaslHost(workspace)
573-
574-
console = get_console()
575-
status = None
576-
if not verbose and console:
577-
status = console.status("[cyan]Verification BCASL (headless)...[/cyan]", spinner="dots")
578-
status.start()
596+
host = CliBcaslHost(workspace, status)
579597

580598
if verbose:
581599
info(f"Running BCASL headless in {workspace}...")

0 commit comments

Comments
 (0)