File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use crate::scanner::VenvInfo;
22
33pub struct App {
44 pub venvs : Vec < VenvInfo > ,
5- pub selected : usize , // index of selected venv
5+ pub selected : usize ,
66}
77
88impl App {
@@ -13,21 +13,18 @@ impl App {
1313 }
1414 }
1515
16- /// Move selection up
1716 pub fn previous ( & mut self ) {
1817 if self . selected > 0 {
1918 self . selected -= 1 ;
2019 }
2120 }
2221
23- /// Move selection down
2422 pub fn next ( & mut self ) {
2523 if self . selected + 1 < self . venvs . len ( ) {
2624 self . selected += 1 ;
2725 }
2826 }
2927
30- /// Get the currently selected venv, if any
3128 pub fn selected_venv ( & self ) -> Option < & VenvInfo > {
3229 self . venvs . get ( self . selected )
3330 }
Original file line number Diff line number Diff line change @@ -7,19 +7,28 @@ use std::env;
77use app:: App ;
88use scanner:: scan_for_venvs;
99use ui:: draw_ui;
10+ use utils:: delete_venv;
1011
1112fn main ( ) {
1213 let cwd = env:: current_dir ( ) . unwrap ( ) ;
1314 let venvs = scan_for_venvs ( & cwd) ;
1415
1516 let mut app = App :: new ( venvs) ;
1617
17- // Simulate some navigation
1818 draw_ui ( & app) ;
19+
1920 println ! ( "\n -- Moving down --" ) ;
2021 app. next ( ) ;
2122 draw_ui ( & app) ;
23+
2224 println ! ( "\n -- Moving up --" ) ;
2325 app. previous ( ) ;
2426 draw_ui ( & app) ;
27+
28+ if let Some ( sel) = app. selected_venv ( ) {
29+ println ! ( "\n Currently selected venv: {}" , sel. path. display( ) ) ;
30+ println ! ( "[Dry-run] Would delete: {}" , sel. path. display( ) ) ;
31+ // Uncomment to actually delete:
32+ delete_venv ( & sel. path ) . unwrap ( ) ;
33+ }
2534}
You can’t perform that action at this time.
0 commit comments