pub fn to_cmd_result(
        &self,
        file: &Path,
        args: &Option<String>,
        _screen: &mut Screen,
        con: &AppContext,
    ) -> io::Result<AppStateCmdResult> {
        Ok(if self.from_shell {
            if let Some(ref export_path) = con.launch_args.cmd_export_path {
                // Broot was probably launched as br.
                // the whole command is exported in the passed file
                let f = OpenOptions::new().append(true).open(export_path)?;
                writeln!(&f, "{}", self.shell_exec_string(file, args))?;
                AppStateCmdResult::Quit
            } else if let Some(ref export_path) = con.launch_args.file_export_path {
                // old version of the br function: only the file is exported
                // in the passed file
                let f = OpenOptions::new().append(true).open(export_path)?;
                writeln!(&f, "{}", file.to_string_lossy())?;
                AppStateCmdResult::Quit
            } else {
                AppStateCmdResult::DisplayError(
                    "this verb needs broot to be launched as `br`. Try `broot --install` if necessary.".to_string()
                )
            }
        } else {
            let launchable = external::Launchable::program(self.exec_token(file, args))?;
            if self.leave_broot {
                AppStateCmdResult::from(launchable)
            } else {
                info!("Executing not leaving, launchable {:?}", launchable);
                let execution = launchable.execute();
                match execution {
                    Ok(()) => {
                        debug!("ok");
                        AppStateCmdResult::RefreshState
                    }
                    Err(e) => {
                        warn!("launchable failed : {:?}", e);
                        AppStateCmdResult::DisplayError(e.to_string())
                    }
                }
            }
        })
    }
/// build the cmd result for a verb defined with an exec pattern.
/// Calling this function on a built-in doesn't make sense
build the cmd result for a verb defined with an exec pattern.
Calling this function on a built-in doesn't make sense
build the cmd result for a verb defined with an exec pattern . Calling this function on a built - in doesn ' t make sense
pub fn to_cmd_result(
        &self,
        file: &Path,
        args: &Option<String>,
        _screen: &mut Screen,
        con: &AppContext,
    ) -> io::Result<AppStateCmdResult> {
        Ok(if self.from_shell {
            if let Some(ref export_path) = con.launch_args.cmd_export_path {
                // Broot was probably launched as br.
                // the whole command is exported in the passed file
                let f = OpenOptions::new().append(true).open(export_path)?;
                writeln!(&f, "{}", self.shell_exec_string(file, args))?;
                AppStateCmdResult::Quit
            } else if let Some(ref export_path) = con.launch_args.file_export_path {
                // old version of the br function: only the file is exported
                // in the passed file
                let f = OpenOptions::new().append(true).open(export_path)?;
                writeln!(&f, "{}", file.to_string_lossy())?;
                AppStateCmdResult::Quit
            } else {
                AppStateCmdResult::DisplayError(
                    "this verb needs broot to be launched as `br`. Try `broot --install` if necessary.".to_string()
                )
            }
        } else {
            let launchable = external::Launchable::program(self.exec_token(file, args))?;
            if self.leave_broot {
                AppStateCmdResult::from(launchable)
            } else {
                info!("Executing not leaving, launchable {:?}", launchable);
                let execution = launchable.execute();
                match execution {
                    Ok(()) => {
                        debug!("ok");
                        AppStateCmdResult::RefreshState
                    }
                    Err(e) => {
                        warn!("launchable failed : {:?}", e);
                        AppStateCmdResult::DisplayError(e.to_string())
                    }
                }
            }
        })
    }
pub fn to_cmd_result ( & self , file : & Path , args : & Option < String > , _screen : & mut Screen , con : & AppContext , ) -> io :: Result < AppStateCmdResult > { Ok ( if self . from_shell { if let Some ( ref export_path ) = con . launch_args . cmd_export_path { // Broot was probably launched as br. // the whole command is exported in the passed file let f = OpenOptions :: new ( ) . append ( true ) . open ( export_path ) ? ; writeln ! ( f " " self shell_exec_string ( file args ) ) ? ; AppStateCmdResult :: Quit } else if let Some ( ref export_path ) = con . launch_args . file_export_path { // old version of the br function: only the file is exported // in the passed file let f = OpenOptions :: new ( ) . append ( true ) . open ( export_path ) ? ; writeln ! ( f " " file to_string_lossy ( ) ) ? ; AppStateCmdResult :: Quit } else { AppStateCmdResult :: DisplayError ( " " . to_string ( ) ) } } else { let launchable = external :: Launchable :: program ( self . exec_token ( file , args ) ) ? ; if self . leave_broot { AppStateCmdResult :: from ( launchable ) } else { info ! ( " " launchable ) ; let execution = launchable . execute ( ) ; match execution { Ok ( ( ) ) => { debug ! ( " " ) ; AppStateCmdResult :: RefreshState } Err ( e ) => { warn ! ( " " e ) ; AppStateCmdResult :: DisplayError ( e . to_string ( ) ) } } } } ) }
build the cmd result for a verb defined with an exec pattern.
build the cmd result for a verb defined with an exec pattern .
&self
file
&Path
args
&Option<String>
_screen
&mut Screen
con
&AppContext
&self
file
&Path
args
&Option<String>
_screen
&mut Screen
con
&AppContext