From 896f987f2705d1c5152d6c0741c377e3612f048a Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Tue, 26 May 2020 23:27:58 -0400 Subject: prepopulating editor with post body when editing --- src/ed.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ed.rs') 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 { } } -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") { @@ -35,6 +35,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) -- cgit 1.4.1-2-gfad0