Skip to content

Commit a5e24a7

Browse files
feat: Add --skip-confirmation flag
1 parent 79eb752 commit a5e24a7

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

tui/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ struct Args {
3030
#[arg(default_value_t = Theme::Default)]
3131
#[arg(help = "Set the theme to use in the application")]
3232
theme: Theme,
33+
#[arg(
34+
short = 'y',
35+
long,
36+
help = "Skip confirmation prompt before executing commands"
37+
)]
38+
skip_confirmation: bool,
3339
#[arg(long, default_value_t = false)]
3440
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
3541
override_validation: bool,
@@ -38,7 +44,7 @@ struct Args {
3844
fn main() -> io::Result<()> {
3945
let args = Args::parse();
4046

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);
4248

4349
stdout().execute(EnterAlternateScreen)?;
4450
enable_raw_mode()?;

tui/src/state.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub struct AppState {
6262
drawable: bool,
6363
#[cfg(feature = "tips")]
6464
tip: &'static str,
65+
skip_confirmation: bool,
6566
}
6667

6768
pub enum Focus {
@@ -79,7 +80,7 @@ pub struct ListEntry {
7980
}
8081

8182
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 {
8384
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
8485
let root_id = tabs[0].tree.root().id();
8586

@@ -97,6 +98,7 @@ impl AppState {
9798
drawable: false,
9899
#[cfg(feature = "tips")]
99100
tip: get_random_tip(),
101+
skip_confirmation,
100102
};
101103

102104
state.update_items();
@@ -678,14 +680,18 @@ impl AppState {
678680
}
679681
}
680682

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+
}
689695
} else {
690696
self.go_to_selected_dir();
691697
}

0 commit comments

Comments
 (0)