/// replace a group in the execution string, using
///  data from the user input and from the selected line
replace a group in the execution string, using
data from the user input and from the selected line
replace a group in the execution string using data from the user input and from the selected line
fn do_exec_replacement(
    ec: &Captures<'_>,
    replacement_map: &HashMap<String, String>,
) -> String {
    let name = ec.get(1).unwrap().as_str();
    if let Some(cap) = replacement_map.get(name) {
        let cap = cap.as_str();
        if let Some(fmt) = ec.get(2) {
            match fmt.as_str() {
                "path-from-directory" => {
                    if cap.starts_with('/') {
                        cap.to_string()
                    } else {
                        normalize_path(
                            format!("{}/{}", replacement_map.get("directory").unwrap(), cap)
                        )
                    }
                }
                "path-from-parent" => {
                    if cap.starts_with('/') {
                        cap.to_string()
                    } else {
                        normalize_path(
                            format!("{}/{}", replacement_map.get("parent").unwrap(), cap)
                        )
                    }
                }
                _ => {
                    format!("invalid format: {:?}", fmt.as_str())
                }
            }
        } else {
            cap.to_string()
        }
    } else {
        format!("{{{}}}", name)
    }
}
fn do_exec_replacement ( ec : & Captures < ' _ > , replacement_map : & HashMap < String , String > , ) -> String { let name = ec . get ( 1 ) . unwrap ( ) . as_str ( ) ; if let Some ( cap ) = replacement_map . get ( name ) { let cap = cap . as_str ( ) ; if let Some ( fmt ) = ec . get ( 2 ) { match fmt . as_str ( ) { " " => { if cap . starts_with ( '/' ) { cap . to_string ( ) } else { normalize_path ( format ! ( " " replacement_map get ( " " ) unwrap ( ) cap ) ) } } " " => { if cap . starts_with ( '/' ) { cap . to_string ( ) } else { normalize_path ( format ! ( " " replacement_map get ( " " ) unwrap ( ) cap ) ) } } _ => { format ! ( " " fmt as_str ( ) ) } } } else { cap . to_string ( ) } } else { format ! ( " " name ) } }
replace a group in the execution string, using
data from the user input and from the selected line
replace a group in the execution string using data from the user input and from the selected line
ec
&Captures<'_>
replacement_map
&HashMap<String, String>