Add Heroic support (#46)

This commit is contained in:
Philip Kristoffersen
2022-03-17 16:51:38 +01:00
committed by GitHub
parent 3f5c99c30e
commit d0b76b664c
12 changed files with 275 additions and 15 deletions
+17 -7
View File
@@ -24,13 +24,13 @@ impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
}
fn get_shortcuts(&self) -> Result<Vec<LegendaryGame>, Box<dyn Error>> {
let legendary_command = Command::new("legendary")
.arg("list-installed")
.arg("--json")
.output()?;
let json = String::from_utf8_lossy(&legendary_command.stdout);
let legendary_ouput = from_str(&json)?;
Ok(legendary_ouput)
let legendary_string = self
.settings
.executable
.clone()
.unwrap_or("legendary".to_string());
let legendary = legendary_string.as_str();
execute_legendary_command(legendary)
}
#[cfg(target_family = "unix")]
@@ -48,3 +48,13 @@ impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
}
}
}
fn execute_legendary_command(program: &str) -> Result<Vec<LegendaryGame>, Box<dyn Error>> {
let legendary_command = Command::new(program)
.arg("list-installed")
.arg("--json")
.output()?;
let json = String::from_utf8_lossy(&legendary_command.stdout);
let legendary_ouput = from_str(&json)?;
Ok(legendary_ouput)
}