Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(skipconfirmation): not working when paired with config auto_execute #972

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ Note that crates installed using `cargo install` require manual updating with `c
Linutil supports configuration through a TOML config file. Path to the file can be specified with `--config` (or `-c`).

Available options:
- `auto_execute` - a list of commands to execute automatically (can be combined with `--skip-confirmation`)
- `auto_execute` - A list of commands to execute automatically (can be combined with `--skip-confirmation`)
- `skip_confirmation` - Boolean ( Equal to `--skip-confirmation`)
- `size_bypass` - Boolean ( Equal to `--size-bypass` )

Example config:
```toml
Expand All @@ -118,6 +120,9 @@ auto_execute = [
"Alacritty",
"Kitty"
]

skip_confirmation = true
size_bypass = true
```

```bash
Expand Down
33 changes: 16 additions & 17 deletions tui/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,22 @@ impl AppState {
}

fn spawn_confirmprompt(&mut self) {
let cmd_names: Vec<_> = self
.selected_commands
.iter()
.map(|node| node.name.as_str())
.collect();
if self.skip_confirmation {
self.handle_confirm_command();
} else {
let cmd_names: Vec<_> = self
.selected_commands
.iter()
.map(|node| node.name.as_str())
.collect();

let prompt = ConfirmPrompt::new(&cmd_names);
self.focus = Focus::ConfirmationPrompt(Float::new(
Box::new(prompt),
CONFIRM_PROMPT_FLOAT_SIZE,
CONFIRM_PROMPT_FLOAT_SIZE,
));
let prompt = ConfirmPrompt::new(&cmd_names);
self.focus = Focus::ConfirmationPrompt(Float::new(
Box::new(prompt),
CONFIRM_PROMPT_FLOAT_SIZE,
CONFIRM_PROMPT_FLOAT_SIZE,
));
}
}

fn get_list_item_shortcut(&self) -> Box<[Shortcut]> {
Expand Down Expand Up @@ -795,12 +799,7 @@ impl AppState {
self.selected_commands.push(node);
}
}

if self.skip_confirmation {
self.handle_confirm_command();
} else {
self.spawn_confirmprompt();
}
self.spawn_confirmprompt();
}
SelectedItem::None => {}
}
Expand Down
Loading