aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2023-02-05 23:47:19 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-02-05 23:47:19 +0100
commit38ff76aad91bc1ce344cdb08366c23523dbb8e1b (patch)
tree932ad48301d34918cde4ca75af20a2c08a6f55e9
parent252c2ca40d805e8190b70e5599e44ee632a99778 (diff)
downloadFlightCore-38ff76aad91bc1ce344cdb08366c23523dbb8e1b.tar.gz
FlightCore-38ff76aad91bc1ce344cdb08366c23523dbb8e1b.zip
feat: Parse for Northstar Launcher version
-rw-r--r--src-tauri/bindings/ParsedLogResults.ts2
-rw-r--r--src-tauri/src/repair_and_verify/log_handling.rs26
2 files changed, 25 insertions, 3 deletions
diff --git a/src-tauri/bindings/ParsedLogResults.ts b/src-tauri/bindings/ParsedLogResults.ts
index 9d9d5c63..5352fc7e 100644
--- a/src-tauri/bindings/ParsedLogResults.ts
+++ b/src-tauri/bindings/ParsedLogResults.ts
@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
-export interface ParsedLogResults { installed_mods: Array<string>, } \ No newline at end of file
+export interface ParsedLogResults { northstar_launcher_version: string, installed_mods: Array<string>, } \ No newline at end of file
diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs
index 2b394a23..e272d056 100644
--- a/src-tauri/src/repair_and_verify/log_handling.rs
+++ b/src-tauri/src/repair_and_verify/log_handling.rs
@@ -5,6 +5,7 @@ use ts_rs::TS;
#[derive(Serialize, Deserialize, Debug, Clone, TS)]
#[ts(export)]
pub struct ParsedLogResults {
+ northstar_launcher_version: String,
installed_mods: Vec<String>,
}
@@ -31,12 +32,33 @@ fn parse_given_log_text_for_installed_mods(log_text: String) -> Result<Vec<Strin
return Ok(mods);
}
+/// Parse logs for Northstar launcher version
+fn parse_for_northstar_launcher_version(log_text: String) -> Result<String, String> {
+ let regex = Regex::new(r"(?m)NorthstarLauncher version: (.*)\n").unwrap();
+
+ // result will be an iterator over tuples containing the start and end indices for each match in the string
+ let mut result = regex.captures_iter(&log_text);
+
+ // Return found Northstar launcher version number
+ match result.next() {
+ None => Err("Couldn't parse Northstar launcher version".to_string()),
+ Some(mat) => match mat.get(1) {
+ None => Err("Couldn't parse Northstar launcher version".to_string()),
+ Some(mod_name) => Ok(mod_name.as_str().to_string()),
+ },
+ }
+}
+
/// Parse logs for installed mods
#[tauri::command]
pub async fn parse_given_log_text(log_text: String) -> Result<ParsedLogResults, String> {
- let installed_mods = parse_given_log_text_for_installed_mods(log_text)?;
+ let installed_mods = parse_given_log_text_for_installed_mods(log_text.clone())?;
+ let northstar_launcher_version = parse_for_northstar_launcher_version(log_text)?;
- let parsed_log_results = ParsedLogResults { installed_mods };
+ let parsed_log_results = ParsedLogResults {
+ northstar_launcher_version,
+ installed_mods,
+ };
// Return the parsed results
return Ok(parsed_log_results);