Skip to content

Commit 7c6a1b3

Browse files
committed
Add RestartAll command
1 parent acdd888 commit 7c6a1b3

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

src/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@ daemonize = "0.5.0"
9191
winapi = { version = "0.3", features = ["consoleapi", "winuser"] }
9292

9393
[lints.clippy]
94-
while_let_loop = "allow"
9594
collapsible_else_if = "allow"
95+
collapsible_if = "allow"
96+
while_let_loop = "allow"

src/app.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,16 @@ impl App {
655655
}
656656
}
657657
}
658+
AppEvent::RestartAll => {
659+
for proc in &mut self.state.procs {
660+
proc.target_state = TargetState::Started;
661+
if proc.is_up() {
662+
pc.send(KernelCommand::ProcCmd(proc.id, ProcCmd::Stop));
663+
} else {
664+
pc.send(KernelCommand::ProcCmd(proc.id, ProcCmd::Start));
665+
}
666+
}
667+
}
658668
AppEvent::ForceRestartProc => {
659669
if let Some(proc) = self.state.get_current_proc_mut() {
660670
proc.target_state = TargetState::Started;
@@ -665,6 +675,16 @@ impl App {
665675
}
666676
}
667677
}
678+
AppEvent::ForceRestartAll => {
679+
for proc in &mut self.state.procs {
680+
proc.target_state = TargetState::Started;
681+
if proc.is_up() {
682+
pc.send(KernelCommand::ProcCmd(proc.id, ProcCmd::Kill));
683+
} else {
684+
pc.send(KernelCommand::ProcCmd(proc.id, ProcCmd::Start));
685+
}
686+
}
687+
}
668688

669689
AppEvent::ScrollUpLines { n } => {
670690
if let Some(proc) = self.state.get_current_proc_mut() {

src/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ pub enum AppEvent {
2929
TermProc,
3030
KillProc,
3131
RestartProc,
32+
RestartAll,
3233
RenameProc { name: String },
3334
ForceRestartProc,
35+
ForceRestartAll,
3436
ShowAddProc,
3537
ShowRenameProc,
3638
AddProc { cmd: String, name: Option<String> },
@@ -79,8 +81,10 @@ impl AppEvent {
7981
AppEvent::TermProc => "Stop".to_string(),
8082
AppEvent::KillProc => "Kill".to_string(),
8183
AppEvent::RestartProc => "Restart".to_string(),
84+
AppEvent::RestartAll => "Restart all".to_string(),
8285
AppEvent::RenameProc { name } => format!("Rename to \"{}\"", name),
8386
AppEvent::ForceRestartProc => "Force restart".to_string(),
87+
AppEvent::ForceRestartAll => "Force restart all".to_string(),
8488
AppEvent::ShowAddProc => "New process dialog".to_string(),
8589
AppEvent::ShowRenameProc => "Rename process dialog".to_string(),
8690
AppEvent::AddProc { cmd, name: _ } => format!("New process `{}`", cmd),

src/modal/commands_menu.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Modal for CommandsMenuModal {
207207
&mut cursor,
208208
);
209209

210-
frame.set_cursor(cursor.0, cursor.1);
210+
frame.set_cursor_position((cursor.0, cursor.1));
211211
}
212212
}
213213

@@ -228,8 +228,10 @@ fn get_commands(search: &str) -> Vec<CommandInfo> {
228228
("term-proc", AppEvent::TermProc),
229229
("kill-proc", AppEvent::KillProc),
230230
("restart-proc", AppEvent::RestartProc),
231+
("restart-all", AppEvent::RestartAll),
231232
("duplicate-proc", AppEvent::DuplicateProc),
232233
("force-restart-proc", AppEvent::ForceRestartProc),
234+
("force-restart-all", AppEvent::ForceRestartAll),
233235
("show-add-proc", AppEvent::ShowAddProc),
234236
("show-rename-proc", AppEvent::ShowRenameProc),
235237
("show-remove-proc", AppEvent::ShowRemoveProc),

0 commit comments

Comments
 (0)