/// Opens the editor specified by the $EDITOR environment variable (fallback `vi`)
/// and returns the saved text when the editor is closed.
///
/// # Arguments
///
///  * `placeholder` - Text that will be present in the temporary file being edited
///
Opens the editor specified by the $EDITOR environment variable (fallback `vi`)
and returns the saved text when the editor is closed.
Opens the editor specified by the $EDITOR environment variable ( fallback ` vi ` ) and returns the saved text when the editor is closed .
pub fn input_from_editor(placeholder: &str) -> Result<String, EditorInputError> {
    let editor = var("EDITOR").unwrap_or("vi".to_string());
    let mut tmpfile = NamedTempFile::new()?;
    tmpfile.write_all(placeholder.as_bytes())?;
    let file_path = tmpfile.into_temp_path();
    let status = Command::new(editor).arg(&file_path).status()?;
    if !status.success() {
        return Err(EditorInputError::ExitStatus(status));
    }
    let mut editable = String::new();
    File::open(file_path)?.read_to_string(&mut editable)?;
    Ok(editable)
}
pub fn input_from_editor ( placeholder : & str ) -> Result < String , EditorInputError > { let editor = var ( " " ) . unwrap_or ( " " . to_string ( ) ) ; let mut tmpfile = NamedTempFile :: new ( ) ? ; tmpfile . write_all ( placeholder . as_bytes ( ) ) ? ; let file_path = tmpfile . into_temp_path ( ) ; let status = Command :: new ( editor ) . arg ( & file_path ) . status ( ) ? ; if ! status . success ( ) { return Err ( EditorInputError :: ExitStatus ( status ) ) ; } let mut editable = String :: new ( ) ; File :: open ( file_path ) ? . read_to_string ( & mut editable ) ? ; Ok ( editable ) }
Opens the editor specified by the $EDITOR environment variable (fallback `vi`)
and returns the saved text when the editor is closed.
Opens the editor specified by the $EDITOR environment variable ( fallback ` vi ` ) and returns the saved text when the editor is closed .
placeholder
&str