~nicohman/eidolon

97f3aea6e10b402e356d7d458b759aaaf2b414e6 — nicohman 2 years ago 11d8340
Add autoscan config option to update eidolon after every command
2 files changed, 30 insertions(+), 21 deletions(-)

M src/eidolon.rs
M src/main.rs
M src/eidolon.rs => src/eidolon.rs +4 -1
@@ 574,13 574,14 @@ pub mod config {
    use crate::{helper::*, *};
    use regex::Regex;
    /// Eidolon's user config
    #[derive(Serialize, Deserialize, Debug)]
    #[derive(Serialize, Deserialize, Debug, Clone)]
    pub struct Config {
        pub steam_dirs: Vec<String>,
        pub menu_command: String,
        pub prefix_command: String,
        #[serde(default = "default_blocked")]
        pub blocked: Vec<String>,
        pub autoscan: bool,
    }
    impl Config {
        /// Default config


@@ 591,6 592,7 @@ pub mod config {
                    .to_string(),
                prefix_command: "".to_string(),
                blocked: default_blocked(),
                autoscan: false
            }
        }
    }


@@ 620,6 622,7 @@ pub mod config {
            menu_command: String::from(old.menu_command),
            prefix_command: String::from(old.prefix_command),
            blocked: default_blocked(),
            autoscan: false
        };
        info!("Creating and writing to new config file");
        OpenOptions::new()

M src/main.rs => src/main.rs +26 -20
@@ 91,26 91,32 @@ fn interpret_args() {
            }
        }
        Update { check_gog } => {
            update_steam(config.steam_dirs);
            update_lutris();
            update_itch();
            if check_gog {
                let games = get_games();
                for game in games {
                    let mut loaded = read_game(game.as_str()).unwrap();
                    if loaded.typeg == GameType::Exe {
                        let path = PathBuf::from(&loaded.command)
                            .parent()
                            .unwrap()
                            .to_path_buf();
                        if path.join("gameinfo").is_file() && path.join("start.sh").is_file() {
                            println!("Found possible GOG game {}. Converting", check_gog);
                            loaded.command = path.to_str().unwrap().to_string();
                            loaded.typeg = GameType::WyvernGOG;
                            rm_game(game);
                            add_game(loaded);
                        }
                    }
            update_all(check_gog, config.clone());
        }
    }
    if config.autoscan {
        update_all(false, config);
    }
}
fn update_all(check_gog: bool, config: Config) {
    update_steam(config.steam_dirs);
    update_lutris();
    update_itch();
    if check_gog {
        let games = get_games();
        for game in games {
            let mut loaded = read_game(game.as_str()).unwrap();
            if loaded.typeg == GameType::Exe {
                let path = PathBuf::from(&loaded.command)
                    .parent()
                    .unwrap()
                    .to_path_buf();
                if path.join("gameinfo").is_file() && path.join("start.sh").is_file() {
                    println!("Found possible GOG game {}. Converting", check_gog);
                    loaded.command = path.to_str().unwrap().to_string();
                    loaded.typeg = GameType::WyvernGOG;
                    rm_game(game);
                    add_game(loaded);
                }
            }
        }