aboutsummaryrefslogtreecommitdiffstats
path: root/src/edit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/edit.rs')
-rw-r--r--src/edit.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/edit.rs b/src/edit.rs
index 178e188..cb59366 100644
--- a/src/edit.rs
+++ b/src/edit.rs
@@ -3,6 +3,14 @@ use crate::prelude::*;
use std::io::{Read as _, Write as _};
pub fn edit(contents: &str, help: &str) -> Result<String> {
+ if ! atty::is(atty::Stream::Stdin) {
+ // directly read from piped content
+ return match std::io::read_to_string(std::io::stdin()) {
+ Err(e) => Err(Error::FailedToReadFromStdin{ err: e }),
+ Ok(res) => Ok(res),
+ };
+ }
+
let mut var = "VISUAL";
let editor = std::env::var_os(var).unwrap_or_else(|| {
var = "EDITOR";