cli_text_editor

Function cli_text_editor 

Source
pub fn cli_text_editor(contents: &str) -> Result<String, CliError>
Expand description

Opens a text editor for the user to edit content.

Creates a temporary file with the provided contents, opens it in the user’s preferred text editor, and returns the edited content. The editor used is determined by the VISUAL or EDITOR environment variables, with sensible defaults for each platform.

§Arguments

  • contents - The initial content to populate the editor with

§Returns

Returns Ok(String) with the edited content on success, or a CliError if the editor fails to launch or exits with an error.

§Example

use falcon_cli::cli_text_editor;

let initial = "Edit this text...";
match cli_text_editor(initial) {
    Ok(edited) => println!("New content: {}", edited),
    Err(e) => eprintln!("Error: {}", e),
}