/// Show the origin and local location, if any, of the currently highlighted item
/// lastly, show which resource will be used in the build
Show the origin and local location, if any, of the currently highlighted item
lastly, show which resource will be used in the build
Show the origin and local location if any of the currently highlighted item lastly show which resource will be used in the build
pub fn show_res_info(resources: &Resources, settings: &Settings, stdout: &mut Stdout) {
    let mut res_path: Option<PathBuf>;
    let mut ind_res = String::new();
    let bgc = &settings.bg_col_info;
    settings.res_name(&mut ind_res);
    let parent = resources.resource_list[&ind_res]["parent"]
        .as_str()
        .unwrap_or("");
    write!(
        stdout,
        "\r\n{}{}\r the first found resource will be used in the OUTPUT/EFI{}\r\n",
        "\x1b[4m",
        " ".repeat(crossterm::terminal::size().unwrap().0.into()),
        bgc,
    )
    .unwrap();
    res_path = res_exists(&resources.working_dir_path, "INPUT", &ind_res, stdout, bgc);
    let open_core_pkg = &resources.open_core_binaries_path;
    if res_path == None {
        let path;
        match settings.sec_key[0].as_str() {
            "ACPI" => {
                path = resources.octool_config["acpi_path"].as_str().unwrap();
            }
            "Misc" => {
                path = resources.octool_config["tools_path"].as_str().unwrap();
            }
            "UEFI" => {
                path = resources.octool_config["drivers_path"].as_str().unwrap();
            }
            _ => path = "",
        }
        res_path = res_exists(open_core_pkg, path, &ind_res, stdout, bgc);
    }
    if parent.len() > 0 {
        write!(stdout, "\x1B[2K\r\n").unwrap();
        write!(stdout, "{} in Dortania Builds? \x1B[0K", parent).unwrap();
        let res_index = settings
            .resource_ver_indexes
            .get(parent)
            .unwrap_or(&Manifest(0, "".to_string()))
            .0;
        match &resources.dortania[parent]["versions"][res_index]["links"][&settings.build_type] {
            serde_json::Value::String(url) => {
                write!(stdout, "\x1b[32mtrue\r\n").unwrap();
                let res = &resources.dortania[parent]["versions"][res_index];
                crossterm::terminal::disable_raw_mode().unwrap();
                write!(
                    stdout,
                    " {grn}url:{bgc} {}{clr}\r\n {grn}commit date/time:{bgc} {}{clr}\r\n {grn}message:{bgc} {}{clr}\r\n",
                    url,
                    res["date_committed"].as_str().unwrap_or(""),
                    res["commit"]["message"].as_str().unwrap_or("").lines().next().unwrap(),
                    grn = "\x1b[32m",
                    bgc = bgc,
                    clr = "\x1b[0K",
                )
                .unwrap();
                crossterm::terminal::enable_raw_mode().unwrap();
                if res_path == None {
                    res_path = get_or_update_local_parent(
                        parent,
                        &resources.dortania,
                        &settings.build_type,
                        &res_index,
                        false,
                        false,
                        stdout,
                    )
                    .unwrap();
                }
            }
            _ => write!(stdout, "\x1b[31mfalse{}\x1b[0K\r\n", bgc).unwrap(),
        }
        write!(stdout, "\x1B[0K\r\n{} in other? \x1B[0K", parent).unwrap();
        match &resources.other[parent]["versions"][0]["links"][&settings.build_type] {
            serde_json::Value::String(url) => {
                write!(stdout, "\x1b[32mtrue\r\n").unwrap();
                write!(stdout, "{}{}\x1B[0K\r\n", url, bgc).unwrap();
                if res_path == None {
                    res_path = get_or_update_local_parent(
                        parent,
                        &resources.other,
                        &settings.build_type,
                        &0,
                        false,
                        false,
                        stdout,
                    )
                    .unwrap();
                }
            }
            _ => write!(stdout, "\x1b[31mfalse{}\r\n", bgc).unwrap(),
        }
    } else {
        write!(
            stdout,
            "\x1B[33m{} not found in tool_config_files/resource_list.json, skipping prebuilt repos{}\x1B[0K\r\n"
        , &ind_res, bgc )
        .unwrap();
    }
    write!(stdout, "\x1B[2K\r\n").unwrap();
    match res_path {
        None => write!(stdout, "\x1B[31mNo local resource found{}\x1B[0K\r\n", bgc).unwrap(),
        Some(p) => {
            write!(
                stdout,
                "\x1B[32mlocal path to resource that will be used{}\x1B[0K\r\n",
                bgc
            )
            .unwrap();
            let mut out = None;
            for entry in WalkDir::new(p.parent().unwrap())
                .into_iter()
                .filter_map(Result::ok)
            {
                let f_name = String::from(entry.file_name().to_string_lossy());
                if f_name == ind_res {
                    out = Some(entry);
                    break;
                }
            }
            match out {
                Some(outp) => {
                    let outp = String::from(outp.path().to_string_lossy());
                    write!(stdout, "{:?}\x1b[0K\r\n", outp).unwrap();
                }
                _ => write!(
                    stdout,
                    "{:?} \x1b[32mwill be downloaded{}\x1b[0K\r\n",
                    p, bgc
                )
                .unwrap(),
            }
        }
    }
}
pub fn show_res_info ( resources : & Resources , settings : & Settings , stdout : & mut Stdout ) { let mut res_path : Option < PathBuf > ; let mut ind_res = String :: new ( ) ; let bgc = & settings . bg_col_info ; settings . res_name ( & mut ind_res ) ; let parent = resources . resource_list [ & ind_res ] [ " " ] . as_str ( ) . unwrap_or ( " " ) ; write ! ( stdout " \r \n \r \r \n " " \x1b " " " repeat ( crossterm terminal size ( ) unwrap ( ) 0 into ( ) ) bgc ) . unwrap ( ) ; res_path = res_exists ( & resources . working_dir_path , " " , & ind_res , stdout , bgc ) ; let open_core_pkg = & resources . open_core_binaries_path ; if res_path == None { let path ; match settings . sec_key [ 0 ] . as_str ( ) { " " => { path = resources . octool_config [ " " ] . as_str ( ) . unwrap ( ) ; } " " => { path = resources . octool_config [ " " ] . as_str ( ) . unwrap ( ) ; } " " => { path = resources . octool_config [ " " ] . as_str ( ) . unwrap ( ) ; } _ => path = " " , } res_path = res_exists ( open_core_pkg , path , & ind_res , stdout , bgc ) ; } if parent . len ( ) > 0 { write ! ( stdout " \x1B \r \n " ) . unwrap ( ) ; write ! ( stdout " \x1B " parent ) . unwrap ( ) ; let res_index = settings . resource_ver_indexes . get ( parent ) . unwrap_or ( & Manifest ( 0 , " " . to_string ( ) ) ) . 0 ; match & resources . dortania [ parent ] [ " " ] [ res_index ] [ " " ] [ & settings . build_type ] { serde_json :: Value :: String ( url ) => { write ! ( stdout " \x1b \r \n " ) . unwrap ( ) ; let res = & resources . dortania [ parent ] [ " " ] [ res_index ] ; crossterm :: terminal :: disable_raw_mode ( ) . unwrap ( ) ; write ! ( stdout " \r \n \r \n \r \n " url res [ " " ] as_str ( ) unwrap_or ( " " ) res [ " " ] [ " " ] as_str ( ) unwrap_or ( " " ) lines ( ) next ( ) unwrap ( ) grn " \x1b " bgc bgc clr " \x1b " ) . unwrap ( ) ; crossterm :: terminal :: enable_raw_mode ( ) . unwrap ( ) ; if res_path == None { res_path = get_or_update_local_parent ( parent , & resources . dortania , & settings . build_type , & res_index , false , false , stdout , ) . unwrap ( ) ; } } _ => write ! ( stdout " \x1b \x1b \r \n " bgc ) . unwrap ( ) , } write ! ( stdout " \x1B \r \n \x1B " parent ) . unwrap ( ) ; match & resources . other [ parent ] [ " " ] [ 0 ] [ " " ] [ & settings . build_type ] { serde_json :: Value :: String ( url ) => { write ! ( stdout " \x1b \r \n " ) . unwrap ( ) ; write ! ( stdout " \x1B \r \n " url bgc ) . unwrap ( ) ; if res_path == None { res_path = get_or_update_local_parent ( parent , & resources . other , & settings . build_type , & 0 , false , false , stdout , ) . unwrap ( ) ; } } _ => write ! ( stdout " \x1b \r \n " bgc ) . unwrap ( ) , } } else { write ! ( stdout " \x1B \x1B \r \n " ind_res bgc ) . unwrap ( ) ; } write ! ( stdout " \x1B \r \n " ) . unwrap ( ) ; match res_path { None => write ! ( stdout " \x1B \x1B \r \n " bgc ) . unwrap ( ) , Some ( p ) => { write ! ( stdout " \x1B \x1B \r \n " bgc ) . unwrap ( ) ; let mut out = None ; for entry in WalkDir :: new ( p . parent ( ) . unwrap ( ) ) . into_iter ( ) . filter_map ( Result :: ok ) { let f_name = String :: from ( entry . file_name ( ) . to_string_lossy ( ) ) ; if f_name == ind_res { out = Some ( entry ) ; break ; } } match out { Some ( outp ) => { let outp = String :: from ( outp . path ( ) . to_string_lossy ( ) ) ; write ! ( stdout " \x1b \r \n " outp ) . unwrap ( ) ; } _ => write ! ( stdout " \x1b \x1b \r \n " p bgc ) . unwrap ( ) , } } } }
Show the origin and local location, if any, of the currently highlighted item
lastly, show which resource will be used in the build
Show the origin and local location if any of the currently highlighted item lastly show which resource will be used in the build
resources
&Resources
settings
&Settings
stdout
&mut Stdout