pub fn open_file_in_editor(path: &Path) -> Result<()> {
        if !path.exists() {
            return Err(anyhow!("file not found: {:?}", path));
        }

        io::stdout().execute(LeaveAlternateScreen)?;
        defer! {
            io::stdout().execute(EnterAlternateScreen).expect("reset terminal");
        }

        let mut editor = env::var("GIT_EDITOR")
            .ok()
            .or_else(|| env::var("VISUAL").ok())
            .or_else(|| env::var("EDITOR").ok())
            .unwrap_or_else(|| String::from("vi"));
        editor.push_str(&format!(" {}", path.to_string_lossy()));

        let mut editor = editor.split_whitespace();

        let command = editor.next().ok_or_else(|| {
            anyhow!("unable to read editor command")
        })?;

        Command::new(command)
            .args(editor)
            .status()
            .map_err(|e| anyhow!("\"{}\": {}", command, e))?;

        Ok(())
    }
/// opens file at given `path` in an available editor
opens file at given `path` in an available editor
opens file at given ` path ` in an available editor
pub fn open_file_in_editor(path: &Path) -> Result<()> {
        if !path.exists() {
            return Err(anyhow!("file not found: {:?}", path));
        }
        io::stdout().execute(LeaveAlternateScreen)?;
        defer! {
            io::stdout().execute(EnterAlternateScreen).expect("reset terminal");
        }
        let mut editor = env::var("GIT_EDITOR")
            .ok()
            .or_else(|| env::var("VISUAL").ok())
            .or_else(|| env::var("EDITOR").ok())
            .unwrap_or_else(|| String::from("vi"));
        editor.push_str(&format!(" {}", path.to_string_lossy()));
        let mut editor = editor.split_whitespace();
        let command = editor.next().ok_or_else(|| {
            anyhow!("unable to read editor command")
        })?;
        Command::new(command)
            .args(editor)
            .status()
            .map_err(|e| anyhow!("\"{}\": {}", command, e))?;
        Ok(())
    }
pub fn open_file_in_editor ( path : & Path ) -> Result < ( ) > { if ! path . exists ( ) { return Err ( anyhow ! ( " " path ) ) ; } io :: stdout ( ) . execute ( LeaveAlternateScreen ) ? ; defer ! { io stdout ( ) execute ( EnterAlternateScreen ) expect ( " " ) } let mut editor = env :: var ( " " ) . ok ( ) . or_else ( | | env :: var ( " " ) . ok ( ) ) . or_else ( | | env :: var ( " " ) . ok ( ) ) . unwrap_or_else ( | | String :: from ( " " ) ) ; editor . push_str ( & format ! ( " " path to_string_lossy ( ) ) ) ; let mut editor = editor . split_whitespace ( ) ; let command = editor . next ( ) . ok_or_else ( | | { anyhow ! ( " " ) } ) ? ; Command :: new ( command ) . args ( editor ) . status ( ) . map_err ( | e | anyhow ! ( " \" \" " command e ) ) ? ; Ok ( ( ) ) }
opens file at given `path` in an available editor
opens file at given ` path ` in an available editor
path
&Path