diff options
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/install.rs | 8 | ||||
-rw-r--r-- | src/cli/mod.rs | 2 | ||||
-rw-r--r-- | src/cli/updates.rs | 39 |
3 files changed, 49 insertions, 0 deletions
diff --git a/src/cli/install.rs b/src/cli/install.rs new file mode 100644 index 0000000..a8ec5eb --- /dev/null +++ b/src/cli/install.rs @@ -0,0 +1,8 @@ +use crate::errors::CliError; + + + +pub fn install() -> Result<(), CliError> { + + Ok(()) +}
\ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs new file mode 100644 index 0000000..04f7bac --- /dev/null +++ b/src/cli/mod.rs @@ -0,0 +1,2 @@ +pub mod updates; +pub mod install;
\ No newline at end of file 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 |