pub fn list_themes(opt: &Opt) {
    // 1. Iterate over locations
    // 2. Print current location
    // 2. Iterate over TOML files
    // 3. Display themes.
    let locations = locations();
    locations.iter().for_each(|dir| {
        println!("{}:", dir.to_string_lossy());
        if let Some(mut entries) = extra::get_entries(dir) {
            entries.sort();
            entries
                .iter()
                .filter(|x| extra::path_extension(x).unwrap_or_default() == "toml")
                .for_each(|theme| {
                    if let Some(str) = theme.file_name() {
                        if let Some(name) = str.to_str() {
                            match get_theme(theme) {
                                Ok(mut t) => {
                                    t.set_filepath(dir.join(name));
                                    t.set_name();
                                    t.set_active(opt.theme.as_ref());
                                    println!("{}", t);
                                }
                                Err(e) => {
                                    println!(
                                        "- {}: {}",
                                        name.replace(".toml", ""),
                                        e.to_string().yellow()
                                    );
                                }
                            }
                        }
                    }
                });
        }
    })
}
/// Prints out a list of available themes.
Prints out a list of available themes.
Prints out a list of available themes .
pub fn list_themes(opt: &Opt) {
    // 1. Iterate over locations
    // 2. Print current location
    // 2. Iterate over TOML files
    // 3. Display themes.
    let locations = locations();
    locations.iter().for_each(|dir| {
        println!("{}:", dir.to_string_lossy());
        if let Some(mut entries) = extra::get_entries(dir) {
            entries.sort();
            entries
                .iter()
                .filter(|x| extra::path_extension(x).unwrap_or_default() == "toml")
                .for_each(|theme| {
                    if let Some(str) = theme.file_name() {
                        if let Some(name) = str.to_str() {
                            match get_theme(theme) {
                                Ok(mut t) => {
                                    t.set_filepath(dir.join(name));
                                    t.set_name();
                                    t.set_active(opt.theme.as_ref());
                                    println!("{}", t);
                                }
                                Err(e) => {
                                    println!(
                                        "- {}: {}",
                                        name.replace(".toml", ""),
                                        e.to_string().yellow()
                                    );
                                }
                            }
                        }
                    }
                });
        }
    })
}
pub fn list_themes ( opt : & Opt ) { // 1. Iterate over locations // 2. Print current location // 2. Iterate over TOML files // 3. Display themes. let locations = locations ( ) ; locations . iter ( ) . for_each ( | dir | { println ! ( " " dir to_string_lossy ( ) ) ; if let Some ( mut entries ) = extra :: get_entries ( dir ) { entries . sort ( ) ; entries . iter ( ) . filter ( | x | extra :: path_extension ( x ) . unwrap_or_default ( ) == " " ) . for_each ( | theme | { if let Some ( str ) = theme . file_name ( ) { if let Some ( name ) = str . to_str ( ) { match get_theme ( theme ) { Ok ( mut t ) => { t . set_filepath ( dir . join ( name ) ) ; t . set_name ( ) ; t . set_active ( opt . theme . as_ref ( ) ) ; println ! ( " " t ) ; } Err ( e ) => { println ! ( " " name replace ( " " " " ) e to_string ( ) yellow ( ) ) ; } } } } } ) ; } } ) }
Prints out a list of available themes.
Prints out a list of available themes .
opt
&Opt
opt
&Opt