Refactor edit_in_tmpfile()

To offer variant where we can pass the editor as command.
This commit is contained in:
Matthias Beyer 2016-09-08 17:37:10 +02:00
parent 21714660df
commit 501d1f38a2

View file

@ -39,6 +39,10 @@ impl<'a> Edit for FileLockEntry<'a> {
} }
pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> {
edit_in_tmpfile_with_command(rt.editor(), s)
}
pub fn edit_in_tmpfile_with_command(cmd: Command, s: &mut String) -> Result<()> {
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
use std::io::Seek; use std::io::Seek;
use std::io::Read; use std::io::Read;
@ -75,3 +79,4 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> {
Err(EditErrorKind::InstantiateError.into()) Err(EditErrorKind::InstantiateError.into())
} }
} }