summary refs log tree commit diff stats
path: root/src/ed.rs
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-05-26 23:27:58 -0400
committerBen Morrison <ben@gbmor.dev>2020-05-26 23:54:18 -0400
commit896f987f2705d1c5152d6c0741c377e3612f048a (patch)
treef6ed5a1b861c9d3e7a2c474084bc4afb6384190a /src/ed.rs
parentc3c1db696f3b04e4aef06fd2b01e436b1fe06b08 (diff)
downloadclinte-896f987f2705d1c5152d6c0741c377e3612f048a.tar.gz
prepopulating editor with post body when editing
Diffstat (limited to 'src/ed.rs')
-rw-r--r--src/ed.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ed.rs b/src/ed.rs
index 095fd9a..7d52909 100644
--- a/src/ed.rs
+++ b/src/ed.rs
@@ -16,7 +16,7 @@ fn create_tmp_file<'a>() -> Result<String, std::io::Error> {
     }
 }
 
-pub fn call() -> String {
+pub fn call(body: &str) -> String {
     // If they don't have $EDITOR set, just default to nano
     // instead of assuming vim or emacs.
     let editor = match env::var("EDITOR") {
@@ -36,6 +36,11 @@ pub fn call() -> String {
     let tmp_loc = error::helper(create_tmp_file(), "Couldn't create tempfile");
 
     error::helper(
+        fs::write(&tmp_loc, body),
+        "Couldn't populate tempfile with message",
+    );
+
+    error::helper(
         process::Command::new(editor)
             .arg(&tmp_loc)
             .stdin(process::Stdio::inherit())