summaryrefslogtreecommitdiff
path: root/src/cli/updates.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/updates.rs')
-rw-r--r--src/cli/updates.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cli/updates.rs b/src/cli/updates.rs
new file mode 100644
index 0000000..3e0bc5d
--- /dev/null
+++ b/src/cli/updates.rs
@@ -0,0 +1,39 @@
+use thirtyfour::{DesiredCapabilities, WebDriver};
+use tracing::{info, error};
+use std::{path::Path, process::exit};
+
+use toml::Value;
+use crate::{errors::CliError, util::{PackConfig, read_pack_lock, self}};
+
+pub async fn check_updates(cfg: PackConfig) -> Result<(), CliError> {
+ info!("Checking for pack updates for {} ({})", cfg.pack.name,cfg.pack.game_version);
+ let mut old_urls: Vec<String> = Vec::new();
+ if Path::new("./pack.lock").exists() {
+ let lock = read_pack_lock()?;
+
+ for url in lock.mod_versions.keys() {
+ old_urls.push((&lock.mod_versions.get(url).unwrap_or(&Value::String("none".to_string()))).to_string());
+ }
+ } else {
+ error!("No pack.lock found, can't check for updates to something that doesn't exist!");
+ exit(-1);
+ }
+
+ let mut num_updates: u32 = 0;
+
+ let caps = DesiredCapabilities::firefox();
+ let driver = WebDriver::new("http://localhost:9515", caps).await;
+
+ for url in old_urls {
+ info!("Checking for updates to {}", url);
+ }
+ Ok(())
+}
+
+
+pub async fn apply_updates(cfg: PackConfig) -> Result<(), CliError> {
+ info!("Fetching new mod versions and updating pack.lock...");
+ let mod_urls = util::find_updated_urls(cfg.mods.values(), cfg.pack.game_version).await?;
+
+ Ok(())
+} \ No newline at end of file