ask to delete old setup on cli

This commit is contained in:
ALEZ-DEV 2025-12-19 17:57:32 +01:00
parent e41eece4a8
commit e1fee118d6
3 changed files with 41 additions and 0 deletions

View File

@ -24,6 +24,30 @@ pub async fn run(
let mut wine_component: Option<WineComponent> = None;
let mut wine: Option<Wine> = None;
// Deleting old setup
if None == GameConfig::get_config().await.launcher_version {
info!("You seem to have the old setup to play the game.");
info!("do you want to delete it to setup the new one ? (y/n) (default - yes): ");
let input = BufReader::new(tokio::io::stdin())
.lines()
.next_line()
.await
.unwrap();
if None == input
|| Some("".to_string()) == input
|| Some("y".to_string()) == input
|| Some("yes".to_string()) == input
{
info!("Deleting old setup...");
babylonia_terminal_sdk::utils::remove_setup().await;
info!("done!");
} else {
info!("Keeping old setup...");
}
}
loop {
let state_result = GameState::get_current_state().await;
if let Err(error) = state_result {

View File

@ -18,6 +18,7 @@ pub struct GameConfig {
pub is_game_installed: bool,
pub is_game_patched: bool,
pub launch_options: Option<String>,
pub launcher_version: Option<String>,
}
impl GameConfig {
@ -100,6 +101,7 @@ impl Default for GameConfig {
is_game_installed: false,
is_game_patched: false,
launch_options: None,
launcher_version: Some(env!("CARGO_PKG_VERSION").to_string()),
}
}
}

View File

@ -1,3 +1,10 @@
use std::io;
use log::debug;
use tokio::fs::remove_dir_all;
use crate::game_config::GameConfig;
pub mod github_requester;
pub mod kuro_prod_api;
@ -8,3 +15,11 @@ pub fn get_game_name() -> String {
pub fn get_game_name_with_executable() -> String {
format!("{}.exe", get_game_name())
}
pub async fn remove_setup() -> io::Result<()> {
let config_dir = GameConfig::get_config_directory().await;
debug!("Current setup directory : {:?}", config_dir);
remove_dir_all(config_dir).await
}