File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ struct Args {
30
30
#[ arg( default_value_t = Theme :: Default ) ]
31
31
#[ arg( help = "Set the theme to use in the application" ) ]
32
32
theme : Theme ,
33
+ #[ arg(
34
+ short = 'y' ,
35
+ long,
36
+ help = "Skip confirmation prompt before executing commands"
37
+ ) ]
38
+ skip_confirmation : bool ,
33
39
#[ arg( long, default_value_t = false ) ]
34
40
#[ clap( help = "Show all available options, disregarding compatibility checks (UNSAFE)" ) ]
35
41
override_validation : bool ,
@@ -38,7 +44,7 @@ struct Args {
38
44
fn main ( ) -> io:: Result < ( ) > {
39
45
let args = Args :: parse ( ) ;
40
46
41
- let mut state = AppState :: new ( args. theme , args. override_validation ) ;
47
+ let mut state = AppState :: new ( args. theme , args. override_validation , args . skip_confirmation ) ;
42
48
43
49
stdout ( ) . execute ( EnterAlternateScreen ) ?;
44
50
enable_raw_mode ( ) ?;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ pub struct AppState {
62
62
drawable : bool ,
63
63
#[ cfg( feature = "tips" ) ]
64
64
tip : & ' static str ,
65
+ skip_confirmation : bool ,
65
66
}
66
67
67
68
pub enum Focus {
@@ -79,7 +80,7 @@ pub struct ListEntry {
79
80
}
80
81
81
82
impl AppState {
82
- pub fn new ( theme : Theme , override_validation : bool ) -> Self {
83
+ pub fn new ( theme : Theme , override_validation : bool , skip_confirmation : bool ) -> Self {
83
84
let ( temp_dir, tabs) = linutil_core:: get_tabs ( !override_validation) ;
84
85
let root_id = tabs[ 0 ] . tree . root ( ) . id ( ) ;
85
86
@@ -97,6 +98,7 @@ impl AppState {
97
98
drawable : false ,
98
99
#[ cfg( feature = "tips" ) ]
99
100
tip : get_random_tip ( ) ,
101
+ skip_confirmation,
100
102
} ;
101
103
102
104
state. update_items ( ) ;
@@ -678,14 +680,18 @@ impl AppState {
678
680
}
679
681
}
680
682
681
- let cmd_names = self
682
- . selected_commands
683
- . iter ( )
684
- . map ( |node| node. name . as_str ( ) )
685
- . collect :: < Vec < _ > > ( ) ;
686
-
687
- let prompt = ConfirmPrompt :: new ( & cmd_names[ ..] ) ;
688
- self . focus = Focus :: ConfirmationPrompt ( Float :: new ( Box :: new ( prompt) , 40 , 40 ) ) ;
683
+ if self . skip_confirmation {
684
+ self . handle_confirm_command ( ) ;
685
+ } else {
686
+ let cmd_names = self
687
+ . selected_commands
688
+ . iter ( )
689
+ . map ( |node| node. name . as_str ( ) )
690
+ . collect :: < Vec < _ > > ( ) ;
691
+
692
+ let prompt = ConfirmPrompt :: new ( & cmd_names[ ..] ) ;
693
+ self . focus = Focus :: ConfirmationPrompt ( Float :: new ( Box :: new ( prompt) , 40 , 40 ) ) ;
694
+ }
689
695
} else {
690
696
self . go_to_selected_dir ( ) ;
691
697
}
You can’t perform that action at this time.
0 commit comments