/// load config.plist or use a Sample.plist if no valid INPUT plist given
/// and run plist through ocvalidate
load config.plist or use a Sample.plist if no valid INPUT plist given
and run plist through ocvalidate
load config . plist or use a Sample . plist if no valid INPUT plist given and run plist through ocvalidate
pub fn init_plist(
    config_plist: &mut PathBuf,
    resources: &mut Resources,
    settings: &mut Settings,
    stdout: &mut Stdout,
) -> Result<(), Box<dyn Error>> {
    if !config_plist.exists() {
        *config_plist = resources
            .open_core_source_path
            .join("Docs/Sample.plist")
            .to_owned();
        resources.config_plist = Value::from_file(&config_plist)
            .expect(format!("Didn't find valid plist at {:?}", config_plist).as_str());
    }
    write!(
        stdout,
        "\n\x1B[32mValidating\x1B[0m {:?} with {} acidanthera/ocvalidate\r\n",
        config_plist, settings.oc_build_version,
    )?;
    validate_plist(&config_plist, &resources, stdout)?;
    //finish configuring settings
    settings.config_file_name = config_plist.to_str().unwrap().to_owned();
    settings.sec_length[0] = resources.config_plist.as_dictionary().unwrap().keys().len();
    let mut found_key = false;
    let keys: Vec<String> = resources
        .config_plist
        .as_dictionary()
        .unwrap()
        .keys()
        .map(|s| s.to_string())
        .collect();
    for (i, k) in keys.iter().enumerate() {
        if !found_key {
            //highlight first key that is not commented out #
            if !k.starts_with('#') {
                settings.sec_num[0] = i;
                found_key = true;
            }
        }
    }
    Ok(())
}
pub fn init_plist ( config_plist : & mut PathBuf , resources : & mut Resources , settings : & mut Settings , stdout : & mut Stdout , ) -> Result < ( ) , Box < dyn Error > > { if ! config_plist . exists ( ) { * config_plist = resources . open_core_source_path . join ( " " ) . to_owned ( ) ; resources . config_plist = Value :: from_file ( & config_plist ) . expect ( format ! ( " " config_plist ) . as_str ( ) ) ; } write ! ( stdout " \n \x1B \x1B \r \n " config_plist settings oc_build_version ) ? ; validate_plist ( & config_plist , & resources , stdout ) ? ; //finish configuring settings settings . config_file_name = config_plist . to_str ( ) . unwrap ( ) . to_owned ( ) ; settings . sec_length [ 0 ] = resources . config_plist . as_dictionary ( ) . unwrap ( ) . keys ( ) . len ( ) ; let mut found_key = false ; let keys : Vec < String > = resources . config_plist . as_dictionary ( ) . unwrap ( ) . keys ( ) . map ( | s | s . to_string ( ) ) . collect ( ) ; for ( i , k ) in keys . iter ( ) . enumerate ( ) { if ! found_key { //highlight first key that is not commented out # if ! k . starts_with ( '#' ) { settings . sec_num [ 0 ] = i ; found_key = true ; } } } Ok ( ( ) ) }
load config.plist or use a Sample.plist if no valid INPUT plist given
and run plist through ocvalidate
load config . plist or use a Sample . plist if no valid INPUT plist given and run plist through ocvalidate
config_plist
&mut PathBuf
resources
&mut Resources
settings
&mut Settings
stdout
&mut Stdout