fn replacement_map(
        &self,
        file: &Path,
        args: &Option<String>,
        for_shell: bool,
    ) -> HashMap<String, String> {
        let mut map = HashMap::new();
        // first we add the replacements computed from the given path
        let parent = file.parent().unwrap_or(file); // when there's no parent... we take file
        let file_str = path_to_string(file, for_shell);
        let parent_str = path_to_string(parent, for_shell);
        map.insert("file".to_string(), file_str.to_string());
        map.insert("parent".to_string(), parent_str.to_string());
        let dir_str = if file.is_dir() { file_str } else { parent_str };
        map.insert("directory".to_string(), dir_str.to_string());
        // then the ones computed from the user input
        if let Some(args) = args {
            if let Some(r) = &self.args_parser {
                if let Some(input_cap) = r.captures(&args) {
                    for name in r.capture_names().flatten() {
                        if let Some(c) = input_cap.name(name) {
                            map.insert(name.to_string(), c.as_str().to_string());
                        }
                    }
                }
            } else {
                warn!("invocation args given but none expected");
                // maybe tell the user?
            }
        }
        map
    }
/// build the map which will be used to replace braced parts (i.e. like {part}) in
/// the execution pattern
build the map which will be used to replace braced parts  in
the execution pattern
build the map which will be used to replace braced parts in the execution pattern
fn replacement_map(
        &self,
        file: &Path,
        args: &Option<String>,
        for_shell: bool,
    ) -> HashMap<String, String> {
        let mut map = HashMap::new();
        // first we add the replacements computed from the given path
        let parent = file.parent().unwrap_or(file); // when there's no parent... we take file
        let file_str = path_to_string(file, for_shell);
        let parent_str = path_to_string(parent, for_shell);
        map.insert("file".to_string(), file_str.to_string());
        map.insert("parent".to_string(), parent_str.to_string());
        let dir_str = if file.is_dir() { file_str } else { parent_str };
        map.insert("directory".to_string(), dir_str.to_string());
        // then the ones computed from the user input
        if let Some(args) = args {
            if let Some(r) = &self.args_parser {
                if let Some(input_cap) = r.captures(&args) {
                    for name in r.capture_names().flatten() {
                        if let Some(c) = input_cap.name(name) {
                            map.insert(name.to_string(), c.as_str().to_string());
                        }
                    }
                }
            } else {
                warn!("invocation args given but none expected");
                // maybe tell the user?
            }
        }
        map
    }
fn replacement_map ( & self , file : & Path , args : & Option < String > , for_shell : bool , ) -> HashMap < String , String > { let mut map = HashMap :: new ( ) ; // first we add the replacements computed from the given path let parent = file . parent ( ) . unwrap_or ( file ) ; // when there's no parent... we take file let file_str = path_to_string ( file , for_shell ) ; let parent_str = path_to_string ( parent , for_shell ) ; map . insert ( " " . to_string ( ) , file_str . to_string ( ) ) ; map . insert ( " " . to_string ( ) , parent_str . to_string ( ) ) ; let dir_str = if file . is_dir ( ) { file_str } else { parent_str } ; map . insert ( " " . to_string ( ) , dir_str . to_string ( ) ) ; // then the ones computed from the user input if let Some ( args ) = args { if let Some ( r ) = & self . args_parser { if let Some ( input_cap ) = r . captures ( & args ) { for name in r . capture_names ( ) . flatten ( ) { if let Some ( c ) = input_cap . name ( name ) { map . insert ( name . to_string ( ) , c . as_str ( ) . to_string ( ) ) ; } } } } else { warn ! ( " " ) ; // maybe tell the user? } } map }
build the map which will be used to replace braced parts (i.e.
build the map which will be used to replace braced parts ( i . e .
&self
file
&Path
args
&Option<String>
for_shell
bool
&self
file
&Path
args
&Option<String>
for_shell
bool