aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-08 02:21:32 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-08 04:54:07 +0100
commit9fc28c2099b50484a4b3154f64f764904d57334e (patch)
tree5fe0a5f914f1c536d6839cf6bb26ad8525bd8a5d /src
parenta0b0a3c6a57097d56c5c471e5cb72bbde8198da8 (diff)
downloaddialog-rs-9fc28c2099b50484a4b3154f64f764904d57334e.tar.gz
dialog-rs-9fc28c2099b50484a4b3154f64f764904d57334e.tar.bz2
backends/Dialog: Add support for output handling
dialog(1) uses stdin to display the dialog boxes and prints output to stderr (if applicable). This patch changes the command invocation in the Dialog backend to capture stderr. stdin and stdout are inherited from the main process so that dialog can display the dialog boxes and receive user input.
Diffstat (limited to 'src')
-rw-r--r--src/backends/dialog.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backends/dialog.rs b/src/backends/dialog.rs
index b448c05..d50be43 100644
--- a/src/backends/dialog.rs
+++ b/src/backends/dialog.rs
@@ -28,14 +28,18 @@ impl Dialog {
}
}
- fn execute(&self, args: Vec<&str>) -> Result<process::ExitStatus> {
+ fn execute(&self, args: Vec<&str>) -> Result<process::Output> {
let mut args = args;
if let Some(ref backtitle) = self.backtitle {
args.insert(0, "--backtitle");
args.insert(1, backtitle);
}
println!("{:?}", args);
- process::Command::new("dialog").args(args).status()
+ process::Command::new("dialog")
+ .args(args)
+ .stdin(process::Stdio::inherit())
+ .stdout(process::Stdio::inherit())
+ .output()
}
/// Sets the backtitle for the dialog boxes.
@@ -61,7 +65,7 @@ impl Dialog {
self.width = width.to_string();
}
- fn show_box(&self, args: Vec<&str>, title: &Option<String>) -> Result<process::ExitStatus> {
+ fn show_box(&self, args: Vec<&str>, title: &Option<String>) -> Result<process::Output> {
let mut args = args;
if let Some(ref title) = title {
args.insert(0, "--title");
@@ -85,6 +89,7 @@ impl super::Backend for Dialog {
fn show_message(&self, message: &Message) -> Result<()> {
let args = vec!["--msgbox", &message.text];
self.show_box(args, &message.title)
- .and_then(require_success)
+ .and_then(|output| require_success(output.status))
+ .map(|_| ())
}
}