@@ -18,6 +18,7 @@ def register_workspace_commands(
1818 cli : Any ,
1919 click : Any ,
2020 resolve_workspace_path : Callable [[str | None ], str | None ],
21+ require_workspace_path : Callable [[str | None , str ], str ],
2122 emit_and_exit : Callable [[object , int , bool ], None ],
2223 echo_payload : Callable [[object , bool ], None ],
2324 workspace_init_emit : Callable [[str , bool , bool ], None ],
@@ -42,7 +43,9 @@ def workspace():
4243 def workspace_inspect (path , as_json , strict ):
4344 """Inspect workspace state and optionally enforce strict existence checks."""
4445 # Inspection non destructive: lit l'état workspace sans rien modifier.
45- payload = workspace_inspect_payload (resolve_workspace_path (path or "." ))
46+ payload = workspace_inspect_payload (
47+ require_workspace_path (path , "workspace inspect" )
48+ )
4649 if as_json :
4750 if strict and not payload .get ("exists" ):
4851 emit_and_exit (payload , EXIT_WORKSPACE_INVALID , True )
@@ -67,7 +70,9 @@ def workspace_inspect(path, as_json, strict):
6770 def workspace_entrypoint (path , as_json , strict ):
6871 """Return the current workspace entrypoint in compact text or JSON form."""
6972 # Sortie volontairement compacte pour simplifier les scripts shell.
70- payload = workspace_inspect_payload (resolve_workspace_path (path or "." ))
73+ payload = workspace_inspect_payload (
74+ require_workspace_path (path , "workspace entrypoint" )
75+ )
7176 result = {
7277 "workspace" : payload .get ("workspace" ),
7378 "entrypoint" : payload .get ("entrypoint" ),
@@ -88,7 +93,7 @@ def workspace_entrypoint(path, as_json, strict):
8893 def workspace_entrypoint_set (path , entrypoint , as_json ):
8994 """Set and persist an explicit workspace entrypoint."""
9095 payload = workspace_entrypoint_set_payload (
91- resolve_workspace_path (path or ". " ),
96+ require_workspace_path (path , "workspace entrypoint-set " ),
9297 entrypoint ,
9398 )
9499 if as_json :
@@ -112,7 +117,7 @@ def workspace_entrypoint_set(path, entrypoint, as_json):
112117 def workspace_entrypoint_clear (path , as_json ):
113118 """Clear the persisted workspace entrypoint."""
114119 payload = workspace_entrypoint_clear_payload (
115- resolve_workspace_path (path or ". " )
120+ require_workspace_path (path , "workspace entrypoint-clear " )
116121 )
117122 if as_json :
118123 if not payload .get ("ok" ):
@@ -137,7 +142,9 @@ def workspace_entrypoint_clear(path, as_json):
137142 def workspace_files (path , as_json ):
138143 """Show a preview list of Python files discovered in the workspace."""
139144 # Preview partielle: on ne dump pas toute l'arborescence pour rester lisible.
140- payload = workspace_inspect_payload (resolve_workspace_path (path or "." ))
145+ payload = workspace_inspect_payload (
146+ require_workspace_path (path , "workspace files" )
147+ )
141148 result = {
142149 "workspace" : payload .get ("workspace" ),
143150 "python_file_count" : payload .get ("python_file_count" , 0 ),
@@ -190,8 +197,9 @@ def workspace_apply(
190197 require_entrypoint ,
191198 ):
192199 """Apply the full workspace workflow in a single command."""
200+ resolved_path = require_workspace_path (path , "workspace apply" )
193201 args = build_workspace_apply_args (
194- path = path ,
202+ path = resolved_path ,
195203 as_json = bool (as_json ),
196204 with_venv = bool (with_venv ),
197205 entrypoint = entrypoint ,
@@ -246,8 +254,9 @@ def workspace_select(
246254 require_entrypoint ,
247255 ):
248256 """Alias of workspace apply that keeps GUI wording familiarity."""
257+ resolved_path = require_workspace_path (path , "workspace select" )
249258 args = build_workspace_apply_args (
250- path = path ,
259+ path = resolved_path ,
251260 as_json = bool (as_json ),
252261 with_venv = bool (with_venv ),
253262 entrypoint = entrypoint ,
@@ -271,7 +280,7 @@ def workspace_select(
271280 def init_cmd (workspace , as_json , with_venv ):
272281 """Initialize workspace structure and baseline configuration files."""
273282 # Les effets de bord (création fichiers/dossiers) sont encapsulés dans workspace_init_emit.
274- workspace_dir = resolve_workspace_path (workspace or ". " )
283+ workspace_dir = require_workspace_path (workspace , "init " )
275284 workspace_init_emit (workspace_dir , as_json = as_json , with_venv = with_venv )
276285
277286 @cli .command ("config-auto" )
@@ -282,7 +291,7 @@ def config_auto_cmd(workspace, entrypoint, as_json):
282291 """Auto-configure workspace entrypoint and dependency settings."""
283292 # Support d'override explicite via --entrypoint pour bypasser l'auto-détection.
284293 workspace_config_auto_emit (
285- resolve_workspace_path (workspace or ". " ),
294+ require_workspace_path (workspace , "config-auto " ),
286295 entrypoint = entrypoint ,
287296 as_json = as_json ,
288297 )
@@ -294,7 +303,7 @@ def config_auto_cmd(workspace, entrypoint, as_json):
294303 def cfg_auto_cmd (workspace , entrypoint , as_json ):
295304 """Short alias for config-auto."""
296305 workspace_config_auto_emit (
297- resolve_workspace_path (workspace or ". " ),
306+ require_workspace_path (workspace , "cfg-auto " ),
298307 entrypoint = entrypoint ,
299308 as_json = as_json ,
300309 )
@@ -312,7 +321,7 @@ def ws():
312321 def ws_init_cmd (workspace , as_json , with_venv ):
313322 """Initialize workspace using the short ws namespace."""
314323 # Alias strict de `init` pour garder une UX type "git-like".
315- workspace_dir = resolve_workspace_path (workspace or ". " )
324+ workspace_dir = require_workspace_path (workspace , "ws init " )
316325 workspace_init_emit (workspace_dir , as_json = as_json , with_venv = with_venv )
317326
318327 @ws .command ("config-auto" )
@@ -322,7 +331,7 @@ def ws_init_cmd(workspace, as_json, with_venv):
322331 def ws_config_auto_cmd (workspace , entrypoint , as_json ):
323332 """Auto-configure workspace using the short ws namespace."""
324333 workspace_config_auto_emit (
325- resolve_workspace_path (workspace or ". " ),
334+ require_workspace_path (workspace , "ws config-auto " ),
326335 entrypoint = entrypoint ,
327336 as_json = as_json ,
328337 )
@@ -334,7 +343,7 @@ def ws_config_auto_cmd(workspace, entrypoint, as_json):
334343 def ws_entrypoint_set_cmd (workspace , entrypoint , as_json ):
335344 """Set workspace entrypoint through the short ws namespace."""
336345 payload = workspace_entrypoint_set_payload (
337- resolve_workspace_path (workspace or ". " ),
346+ require_workspace_path (workspace , "ws entrypoint-set " ),
338347 entrypoint ,
339348 )
340349 if as_json :
@@ -358,7 +367,7 @@ def ws_entrypoint_set_cmd(workspace, entrypoint, as_json):
358367 def ws_entrypoint_clear_cmd (workspace , as_json ):
359368 """Clear workspace entrypoint through the short ws namespace."""
360369 payload = workspace_entrypoint_clear_payload (
361- resolve_workspace_path (workspace or ". " )
370+ require_workspace_path (workspace , "ws entrypoint-clear " )
362371 )
363372 if as_json :
364373 if not payload .get ("ok" ):
@@ -417,8 +426,9 @@ def ws_apply_cmd(
417426 require_entrypoint ,
418427 ):
419428 """Apply workspace workflow using the short ws namespace."""
429+ resolved_path = require_workspace_path (workspace , "ws apply" )
420430 args = build_workspace_apply_args (
421- path = workspace ,
431+ path = resolved_path ,
422432 as_json = bool (as_json ),
423433 with_venv = bool (with_venv ),
424434 entrypoint = entrypoint ,
@@ -473,8 +483,9 @@ def ws_select_cmd(
473483 require_entrypoint ,
474484 ):
475485 """Select/apply workspace using the short ws namespace."""
486+ resolved_path = require_workspace_path (workspace , "ws select" )
476487 args = build_workspace_apply_args (
477- path = workspace ,
488+ path = resolved_path ,
478489 as_json = bool (as_json ),
479490 with_venv = bool (with_venv ),
480491 entrypoint = entrypoint ,
0 commit comments