pub fn load_config() -> Result<Config, Box<dyn StdError>> {
        let matches = App::new("Plantex")
            .version(env!("CARGO_PKG_VERSION"))
            .about("Game about Plants!")
            .arg(
                Arg::with_name("Resolution")
                    .help("(e.g. =1280x720) 'Sets Resolution to new value'")
                    .takes_value(true)
                    .long("resolution"),
            )
            .arg(
                Arg::with_name("WindowMode")
                    .help("[Windowed, FullScreen] 'Sets WindowMode'")
                    .takes_value(true)
                    .long("windowmode"),
            )
            .arg(
                Arg::with_name("Tessellation")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("tessellation"),
            )
            .arg(
                Arg::with_name("Bloom")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("bloom"),
            )
            .arg(
                Arg::with_name("Vsync")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("vsync"),
            )
            .arg(
                Arg::with_name("HighlightPillar")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("highlight"),
            )
            .arg(
                Arg::with_name("Seed")
                    .help("'Takes a specified seed to generate map'")
                    .takes_value(true)
                    .long("seed"),
            )
            .arg(
                Arg::with_name("File")
                    .help("Takes config file")
                    .takes_value(true)
                    .long("config-file"),
            )
            .arg(
                Arg::with_name("Write_Config_File")
                    .help("'Writes Config File with default values'")
                    .long("write-config"),
            )
            .get_matches();

        let conf = Config::default();

        if matches.is_present("Write_Config_File") {
            if Path::new("config.toml").exists() {
                return Err("Config.toml already exists".into());
            }
            let toml = r#"
[Graphic]
resolution_width = 800
resolution_height = 600
windowmode = "Windowed"
bloom = true
vsync = false

[Game_settings]
seed = 42
highlight_pillar = true
            "#;

            let mut f = File::create("config.toml")?;

            f.write_all(&toml.to_string().into_bytes())?;
        };

        let t_conf = config_toml(conf, &matches)?;
        let conf_final = config_command(t_conf, &matches)?;

        debug!("final config: {:?}", conf_final);
        Ok(conf_final)
    }
/// creates a new Config in three steps:
/// 1. loads default config
/// 2. Overrides from toml config file
/// 3. Overrides from command line
creates a new Config in three steps:
1. loads default config
2. Overrides from toml config file
3. Overrides from command line
creates a new Config in three steps : 1 . loads default config 2 . Overrides from toml config file 3 . Overrides from command line
pub fn load_config() -> Result<Config, Box<dyn StdError>> {
        let matches = App::new("Plantex")
            .version(env!("CARGO_PKG_VERSION"))
            .about("Game about Plants!")
            .arg(
                Arg::with_name("Resolution")
                    .help("(e.g. =1280x720) 'Sets Resolution to new value'")
                    .takes_value(true)
                    .long("resolution"),
            )
            .arg(
                Arg::with_name("WindowMode")
                    .help("[Windowed, FullScreen] 'Sets WindowMode'")
                    .takes_value(true)
                    .long("windowmode"),
            )
            .arg(
                Arg::with_name("Tessellation")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("tessellation"),
            )
            .arg(
                Arg::with_name("Bloom")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("bloom"),
            )
            .arg(
                Arg::with_name("Vsync")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("vsync"),
            )
            .arg(
                Arg::with_name("HighlightPillar")
                    .help("[on/off]")
                    .takes_value(true)
                    .long("highlight"),
            )
            .arg(
                Arg::with_name("Seed")
                    .help("'Takes a specified seed to generate map'")
                    .takes_value(true)
                    .long("seed"),
            )
            .arg(
                Arg::with_name("File")
                    .help("Takes config file")
                    .takes_value(true)
                    .long("config-file"),
            )
            .arg(
                Arg::with_name("Write_Config_File")
                    .help("'Writes Config File with default values'")
                    .long("write-config"),
            )
            .get_matches();
        let conf = Config::default();
        if matches.is_present("Write_Config_File") {
            if Path::new("config.toml").exists() {
                return Err("Config.toml already exists".into());
            }
            let toml = r#"
[Graphic]
resolution_width = 800
resolution_height = 600
windowmode = "Windowed"
bloom = true
vsync = false
[Game_settings]
seed = 42
highlight_pillar = true
            "#;
            let mut f = File::create("config.toml")?;
            f.write_all(&toml.to_string().into_bytes())?;
        };
        let t_conf = config_toml(conf, &matches)?;
        let conf_final = config_command(t_conf, &matches)?;
        debug!("final config: {:?}", conf_final);
        Ok(conf_final)
    }
pub fn load_config ( ) -> Result < Config , Box < dyn StdError > > { let matches = App :: new ( " " ) . version ( env ! ( " " ) ) . about ( " " ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . takes_value ( true ) . long ( " " ) , ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . long ( " " ) , ) . get_matches ( ) ; let conf = Config :: default ( ) ; if matches . is_present ( " " ) { if Path :: new ( " " ) . exists ( ) { return Err ( " " . into ( ) ) ; } let toml = r#"
[Graphic]
resolution_width = 800
resolution_height = 600
windowmode = "Windowed"
bloom = true
vsync = false

[Game_settings]
seed = 42
highlight_pillar = true
            "# ; let mut f = File :: create ( " " ) ? ; f . write_all ( & toml . to_string ( ) . into_bytes ( ) ) ? ; } ; let t_conf = config_toml ( conf , & matches ) ? ; let conf_final = config_command ( t_conf , & matches ) ? ; debug ! ( " " conf_final ) ; Ok ( conf_final ) }
creates a new Config in three steps:
1. loads default config
2.
creates a new Config in three steps : 1 . loads default config 2 .