@@ -295,9 +295,80 @@ def scaffold_plugin_payload(name: str, root_dir: str | None = None) -> dict[str,
295295 return scaffold_plugin (name , root_dir = root_dir )
296296
297297
298+ def run_bcasl_before_compile_sync (workspace : Path ) -> bool :
299+ """Run BCASL pre-compile stage synchronously for the CLI.
300+
301+ Returns:
302+ True if compilation can proceed (success or BCASL disabled), False otherwise.
303+ """
304+ from .output import info , error , success , log
305+ from bcasl .Loader import run_pre_compile
306+
307+ class CliBcaslHost :
308+ def __init__ (self , ws_dir : Path ):
309+ self .workspace_dir = str (ws_dir )
310+ class Logger :
311+ def append (self , msg : str ):
312+ # Strip trailing newline as our log() adds one
313+ log ("BCASL" , msg .rstrip ())
314+ self .log = Logger ()
315+
316+ host = CliBcaslHost (workspace )
317+ info ("Running BCASL pre-compile checks..." )
318+ try :
319+ report = run_pre_compile (host )
320+ except Exception as exc :
321+ error (f"BCASL execution failed: { exc } " )
322+ return False
323+
324+ if report is None :
325+ # report is None if BCASL is disabled or failed silently
326+ return True
327+
328+ if hasattr (report , "ok" ):
329+ if not getattr (report , "ok" ):
330+ error ("BCASL reported security or validation failures." )
331+ return False
332+ success ("BCASL checks passed." )
333+ return True
334+
335+ return True
336+
337+
298338def run_bcasl_headless (args : list [str ]) -> int :
299- # À Connecter à BCASL depuis bcasl/
300- return print ("Pas encore implémenter en Cli" )
339+ """Run BCASL in headless mode for the current workspace."""
340+ from .output import error , success
341+ from bcasl .Loader import run_pre_compile
342+
343+ workspace = Path .cwd ()
344+ if "run" in args :
345+ # If workspace path is provided in args, use it
346+ for i , arg in enumerate (args ):
347+ if arg == "run" and i + 1 < len (args ):
348+ candidate = Path (args [i + 1 ])
349+ if candidate .is_dir ():
350+ workspace = candidate .resolve ()
351+ break
352+
353+ class CliBcaslHost :
354+ def __init__ (self , ws_dir : Path ):
355+ self .workspace_dir = str (ws_dir )
356+ class Logger :
357+ def append (self , msg : str ):
358+ print (msg , end = "" , flush = True )
359+ self .log = Logger ()
360+
361+ host = CliBcaslHost (workspace )
362+ try :
363+ report = run_pre_compile (host )
364+ if report and hasattr (report , "ok" ) and not getattr (report , "ok" ):
365+ error ("\n BCASL found issues." )
366+ return 1
367+ success ("\n BCASL completed successfully." )
368+ return 0
369+ except Exception as exc :
370+ error (f"BCASL failed: { exc } " )
371+ return 1
301372
302373def launch_gui (* , legacy : bool = False ) -> int :
303374 return launch_main_application (
0 commit comments