Skip to content

Commit

Permalink
Fix deletion test
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanse committed Feb 19, 2024
1 parent 2b30d48 commit d943cbc
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,7 @@ impl MainConfig {

fn delete_game(&mut self) -> Result<()> {
let idx = self.game_selector(None)?;

self.delete_game_internal(idx)
}

fn delete_game_internal(&mut self, id: usize) -> Result<()> {
let game = self.games[id].clone();

println!("Executable Path: {}", game.exect_path);
println!("Prefix: {}", game.prefix_path);
let game = self.games[idx].clone();

let confirmation: bool = Confirm::new()
.with_prompt(format!(
Expand All @@ -270,13 +262,21 @@ impl MainConfig {
.ok_or(eyre!("NOthing selected, goodbye"))?;

if confirmation {
self.games.remove(id);
self.save_games()?;
println!("Executable Path: {}", game.exect_path);
println!("Prefix: {}", game.prefix_path);
self.delete_game_internal(idx)?;
println!("Deleted {}", game.name);
Ok(())
} else {
std::process::exit(1);
}

Ok(())
}

fn delete_game_internal(&mut self, id: usize) -> Result<()> {
self.games.remove(id);
self.save_games()?;
Ok(())
}

pub fn game_selector(&self, id: Option<usize>) -> Result<usize> {
Expand Down

0 comments on commit d943cbc

Please sign in to comment.