@@ -330,6 +330,48 @@ def _render_config_tree(config: dict[str, t.Any], colors: Colors) -> list[str]:
330330 return lines
331331
332332
333+ def _render_global_workspace_dirs (
334+ formatter : OutputFormatter ,
335+ colors : Colors ,
336+ global_dir_candidates : list [dict [str , t .Any ]],
337+ ) -> None :
338+ """Render global workspace directories section.
339+
340+ Parameters
341+ ----------
342+ formatter : OutputFormatter
343+ Output formatter.
344+ colors : Colors
345+ Color manager.
346+ global_dir_candidates : list[dict[str, Any]]
347+ List of global workspace directory candidates with metadata.
348+ """
349+ formatter .emit_text ("" )
350+ formatter .emit_text (colors .heading ("Global workspace directories:" ))
351+ for candidate in global_dir_candidates :
352+ path = candidate ["path" ]
353+ source = candidate .get ("source" , "" )
354+ source_prefix = f"{ source } : " if source else ""
355+ if candidate ["exists" ]:
356+ count = candidate ["workspace_count" ]
357+ status = f"{ count } workspace{ 's' if count != 1 else '' } "
358+ if candidate ["active" ]:
359+ status += ", active"
360+ formatter .emit_text (
361+ f" { colors .muted (source_prefix )} { colors .info (path )} "
362+ f"({ colors .success (status )} )"
363+ )
364+ else :
365+ formatter .emit_text (
366+ f" { colors .muted (source_prefix )} { colors .info (path )} ({ status } )"
367+ )
368+ else :
369+ formatter .emit_text (
370+ f" { colors .muted (source_prefix )} { colors .info (path )} "
371+ f"({ colors .muted ('not found' )} )"
372+ )
373+
374+
333375def _output_flat (
334376 workspaces : list [dict [str , t .Any ]],
335377 formatter : OutputFormatter ,
@@ -399,30 +441,7 @@ def output_workspace(ws: dict[str, t.Any], show_path: bool) -> None:
399441
400442 # Output global workspace directories section
401443 if global_dir_candidates :
402- formatter .emit_text ("" )
403- formatter .emit_text (colors .heading ("Global workspace directories:" ))
404- for candidate in global_dir_candidates :
405- path = candidate ["path" ]
406- source = candidate .get ("source" , "" )
407- source_prefix = f"{ source } : " if source else ""
408- if candidate ["exists" ]:
409- count = candidate ["workspace_count" ]
410- status = f"{ count } workspace{ 's' if count != 1 else '' } "
411- if candidate ["active" ]:
412- status += ", active"
413- formatter .emit_text (
414- f" { colors .muted (source_prefix )} { colors .info (path )} "
415- f"({ colors .success (status )} )"
416- )
417- else :
418- formatter .emit_text (
419- f" { colors .muted (source_prefix )} { colors .info (path )} ({ status } )"
420- )
421- else :
422- formatter .emit_text (
423- f" { colors .muted (source_prefix )} { colors .info (path )} "
424- f"({ colors .muted ('not found' )} )"
425- )
444+ _render_global_workspace_dirs (formatter , colors , global_dir_candidates )
426445
427446
428447def _output_tree (
@@ -481,30 +500,7 @@ def _output_tree(
481500
482501 # Output global workspace directories section
483502 if global_dir_candidates :
484- formatter .emit_text ("" )
485- formatter .emit_text (colors .heading ("Global workspace directories:" ))
486- for candidate in global_dir_candidates :
487- path = candidate ["path" ]
488- source = candidate .get ("source" , "" )
489- source_prefix = f"{ source } : " if source else ""
490- if candidate ["exists" ]:
491- count = candidate ["workspace_count" ]
492- status = f"{ count } workspace{ 's' if count != 1 else '' } "
493- if candidate ["active" ]:
494- status += ", active"
495- formatter .emit_text (
496- f" { colors .muted (source_prefix )} { colors .info (path )} "
497- f"({ colors .success (status )} )"
498- )
499- else :
500- formatter .emit_text (
501- f" { colors .muted (source_prefix )} { colors .info (path )} ({ status } )"
502- )
503- else :
504- formatter .emit_text (
505- f" { colors .muted (source_prefix )} { colors .info (path )} "
506- f"({ colors .muted ('not found' )} )"
507- )
503+ _render_global_workspace_dirs (formatter , colors , global_dir_candidates )
508504
509505
510506def command_ls (
@@ -565,28 +561,7 @@ def command_ls(
565561 formatter .emit_text (colors .warning ("No workspaces found." ))
566562 # Still show global workspace directories even with no workspaces
567563 if output_mode == OutputMode .HUMAN :
568- formatter .emit_text ("" )
569- formatter .emit_text (colors .heading ("Global workspace directories:" ))
570- for candidate in global_dir_candidates :
571- path = candidate ["path" ]
572- source = candidate .get ("source" , "" )
573- source_prefix = f"{ source } : " if source else ""
574- if candidate ["exists" ]:
575- if candidate ["active" ]:
576- formatter .emit_text (
577- f" { colors .muted (source_prefix )} { colors .info (path )} "
578- f"({ colors .success ('0 workspaces, active' )} )"
579- )
580- else :
581- formatter .emit_text (
582- f" { colors .muted (source_prefix )} { colors .info (path )} "
583- f"(0 workspaces)"
584- )
585- else :
586- formatter .emit_text (
587- f" { colors .muted (source_prefix )} { colors .info (path )} "
588- f"({ colors .muted ('not found' )} )"
589- )
564+ _render_global_workspace_dirs (formatter , colors , global_dir_candidates )
590565 elif output_mode == OutputMode .JSON :
591566 # Output structured JSON with empty workspaces
592567 output_data = {
0 commit comments