Function plume::get_text
[−]
[src]
pub fn get_text() -> Result<String, Error>
Get some text from the user
This function will:
- find the text editor to use
- if the ${EDITOR} environment variable is set, then its value is used;
- otherwise, this will search for known text editors like nano or vim;
- launch that text editor and capture the text entered by the user;
- return that text.
Examples
let text = plume::get_text()?; println!("Got text:\n{}\n----------", text);
Errors
This function will return failure::Error
instances in a few cases:
- a temporary file could not be created, seeked, read or closed; (see the
tempfile::NamedTempFile
documentation) - the temporary file path is not valid UTF-8; (see the
std::path::Path.to_str()
documentation) - no text editor could be found, either because the
${EDITOR}
environment variable was not set, or because no known text editor was installed; - the command spawn to launch the text editor failed or exited with a non-zero return code;