mirror of
https://github.com/nukesor/pueue
synced 2024-06-29 06:04:21 +00:00
fix: Only ask confirmation for tasks in resetting groups
This commit is contained in:
parent
8316fcb4e2
commit
41a0daef1b
|
@ -173,13 +173,23 @@ impl Client {
|
|||
async fn handle_complex_command(&mut self) -> Result<bool> {
|
||||
// This match handles all "complex" commands.
|
||||
match &self.subcommand {
|
||||
SubCommand::Reset { force, .. } => {
|
||||
SubCommand::Reset { force, groups } => {
|
||||
// Get the current state and check if there're any running tasks.
|
||||
// If there are, ask the user if they really want to reset the state.
|
||||
let state = get_state(&mut self.stream).await?;
|
||||
|
||||
// Get the groups that should be reset.
|
||||
let groups: Vec<String> = if groups.is_empty() {
|
||||
state.groups.keys().cloned().collect()
|
||||
} else {
|
||||
groups.clone()
|
||||
};
|
||||
|
||||
// Check if there're any running tasks for that group
|
||||
let running_tasks = state
|
||||
.tasks
|
||||
.iter()
|
||||
.filter(|(_id, task)| groups.contains(&task.group))
|
||||
.filter_map(|(id, task)| if task.is_running() { Some(*id) } else { None })
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user