File tree Expand file tree Collapse file tree
crates/pixi_cli/src/workspace Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ pub enum Command {
5151 /// Remove a workspace from registry.
5252 #[ clap( visible_alias = "rm" ) ]
5353 Remove ( RemoveArgs ) ,
54+ /// Prune disassociated workspaces from registry.
55+ #[ clap( visible_alias = "pr" ) ]
56+ Prune ( PruneArgs ) ,
5457}
5558
5659pub async fn execute ( args : Args ) -> miette:: Result < ( ) > {
@@ -84,6 +87,25 @@ pub async fn execute(args: Args) -> miette::Result<()> {
8487 & remove_args. name
8588 ) ;
8689 }
90+ Some ( Command :: Prune ( _) ) => {
91+ let mut workspace_registry = WorkspaceRegistry :: load ( ) ?;
92+ let workspace_map = workspace_registry. named_workspaces_map ( ) ;
93+
94+ let names_to_remove: Vec < _ > = workspace_map
95+ . iter ( )
96+ . filter ( |( _, path) | !path. exists ( ) )
97+ . map ( |( name, _) | name. clone ( ) )
98+ . collect ( ) ;
99+
100+ for name in names_to_remove {
101+ workspace_registry. remove_workspace ( & name) . await ?;
102+ eprintln ! ( "{} {}" , console:: style( "removed workspace" ) . green( ) , name) ;
103+ }
104+ eprintln ! (
105+ "{} Workspace registry cleaned" ,
106+ console:: style( console:: Emoji ( "✔ " , "" ) ) . green( ) ,
107+ ) ;
108+ }
87109 None => {
88110 let workspace = WorkspaceLocator :: for_cli ( )
89111 . with_closest_package ( false )
You can’t perform that action at this time.
0 commit comments