fn update(
    sub_cmd: &mut Option<std::process::Command>,
    event_tx_list: &Option<Arc<Mutex<Vec<Sender<()>>>>>,
    verbose_info: &VerboseInfo,
) -> Result<()> {
    // Verbose log for signal.
    if let Some(event_out) = &verbose_info.event_out {
        println!(
            "[{}] Triggering signal '{}' on port {}",
            CMD_NAME, event_out.name, event_out.port
        );
    }

    // Verbose log for command execition.
    if let Some(sub_cmd_repr) = &verbose_info.sub_cmd_repr {
        println!("[{}] Triggering command: {}", CMD_NAME, sub_cmd_repr);
    }

    // Run sub-command, return early on error.
    if let Some(cmd) = sub_cmd {
        cmd.status()
            .map_err(|_| format!("[{}] Failed to run command", CMD_NAME))?;
    }

    // Notify subscribers and forget disconnected subscribers.
    if let Some(event_tx_list) = event_tx_list {
        let tx_list = &mut *event_tx_list.lock().unwrap();
        *tx_list = tx_list.drain(..).filter(|tx| tx.send(()).is_ok()).collect();
    }

    Ok(())
}
/// Run sub-command and notify subscribers.
Run sub-command and notify subscribers.
Run sub - command and notify subscribers .
fn update(
    sub_cmd: &mut Option<std::process::Command>,
    event_tx_list: &Option<Arc<Mutex<Vec<Sender<()>>>>>,
    verbose_info: &VerboseInfo,
) -> Result<()> {
    // Verbose log for signal.
    if let Some(event_out) = &verbose_info.event_out {
        println!(
            "[{}] Triggering signal '{}' on port {}",
            CMD_NAME, event_out.name, event_out.port
        );
    }
    // Verbose log for command execition.
    if let Some(sub_cmd_repr) = &verbose_info.sub_cmd_repr {
        println!("[{}] Triggering command: {}", CMD_NAME, sub_cmd_repr);
    }
    // Run sub-command, return early on error.
    if let Some(cmd) = sub_cmd {
        cmd.status()
            .map_err(|_| format!("[{}] Failed to run command", CMD_NAME))?;
    }
    // Notify subscribers and forget disconnected subscribers.
    if let Some(event_tx_list) = event_tx_list {
        let tx_list = &mut *event_tx_list.lock().unwrap();
        *tx_list = tx_list.drain(..).filter(|tx| tx.send(()).is_ok()).collect();
    }
    Ok(())
}
fn update ( sub_cmd : & mut Option < std :: process :: Command > , event_tx_list : & Option < Arc < Mutex < Vec < Sender < ( ) > > > > > , verbose_info : & VerboseInfo , ) -> Result < ( ) > { // Verbose log for signal. if let Some ( event_out ) = & verbose_info . event_out { println ! ( " " CMD_NAME event_out name event_out port ) ; } // Verbose log for command execition. if let Some ( sub_cmd_repr ) = & verbose_info . sub_cmd_repr { println ! ( " " CMD_NAME sub_cmd_repr ) ; } // Run sub-command, return early on error. if let Some ( cmd ) = sub_cmd { cmd . status ( ) . map_err ( | _ | format ! ( " " CMD_NAME ) ) ? ; } // Notify subscribers and forget disconnected subscribers. if let Some ( event_tx_list ) = event_tx_list { let tx_list = & mut * event_tx_list . lock ( ) . unwrap ( ) ; * tx_list = tx_list . drain ( .. ) . filter ( | tx | tx . send ( ( ) ) . is_ok ( ) ) . collect ( ) ; } Ok ( ( ) ) }
Run sub-command and notify subscribers.
Run sub - command and notify subscribers .
sub_cmd
&mut Option<std::process::Command>
event_tx_list
&Option<Arc<Mutex<Vec<Sender<()>>>>>
verbose_info
&VerboseInfo
sub_cmd
&mut Option<std::process::Command>
event_tx_list
&Option<Arc<Mutex<Vec<Sender<()>>>>>
verbose_info
&VerboseInfo