Phase 5: Ausführung und Output implementieren und archivieren
This commit is contained in:
@@ -158,6 +158,15 @@ pub mod taste {
|
||||
}
|
||||
|
||||
pub trait Host {
|
||||
/// None means the frontend has scheduled a terminal handoff; retry the
|
||||
/// same request after it supplies the child result.
|
||||
fn shell(&mut self, command: &str) -> Result<Option<i32>, crate::errors::RuntimeError> {
|
||||
shell_command(command)
|
||||
.status()
|
||||
.map(|s| Some(s.code().unwrap_or(0)))
|
||||
.map_err(|_| crate::errors::RuntimeError(53))
|
||||
}
|
||||
|
||||
/// Aktuellen Bildschirmzustand anzeigen.
|
||||
fn present(&mut self, screen: &TextScreen);
|
||||
|
||||
@@ -388,3 +397,12 @@ mod tests {
|
||||
assert_eq!(h.next_event(false), None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Shared child command, inheriting the foreground terminal and stdio.
|
||||
pub fn shell_command(command: &str) -> std::process::Command {
|
||||
let mut child = std::process::Command::new(if cfg!(windows) { "cmd" } else { "sh" });
|
||||
if !command.is_empty() {
|
||||
child.args([if cfg!(windows) { "/C" } else { "-c" }, command]);
|
||||
}
|
||||
child
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user