mirror of
https://github.com/nukesor/pueue
synced 2024-09-30 04:53:37 +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> {
|
async fn handle_complex_command(&mut self) -> Result<bool> {
|
||||||
// This match handles all "complex" commands.
|
// This match handles all "complex" commands.
|
||||||
match &self.subcommand {
|
match &self.subcommand {
|
||||||
SubCommand::Reset { force, .. } => {
|
SubCommand::Reset { force, groups } => {
|
||||||
// Get the current state and check if there're any running tasks.
|
// 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.
|
// If there are, ask the user if they really want to reset the state.
|
||||||
let state = get_state(&mut self.stream).await?;
|
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
|
let running_tasks = state
|
||||||
.tasks
|
.tasks
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|(_id, task)| groups.contains(&task.group))
|
||||||
.filter_map(|(id, task)| if task.is_running() { Some(*id) } else { None })
|
.filter_map(|(id, task)| if task.is_running() { Some(*id) } else { None })
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue