Compare commits
3 commits
ea766de5c3
...
91b20693fd
| Author | SHA1 | Date | |
|---|---|---|---|
| 91b20693fd | |||
| f6d47e4b4d | |||
| 86a46f7562 |
4 changed files with 68 additions and 1 deletions
|
|
@ -40,6 +40,11 @@ impl Install {
|
|||
let client = reqwest::Client::new();
|
||||
|
||||
for mod_name in &self.mods {
|
||||
if config.mods.contains_key(mod_name) {
|
||||
println!("{} mod already installed, skipping...", mod_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
let url = format!("{}/project/{}/version", Self::BASE_URL, mod_name);
|
||||
|
||||
let params = InstallQueryParams {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pub mod create;
|
||||
pub mod install;
|
||||
pub mod search;
|
||||
pub mod update;
|
||||
|
|
|
|||
28
src/commands/update.rs
Normal file
28
src/commands/update.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use std::error::Error;
|
||||
|
||||
pub struct Update {
|
||||
mods_only: bool,
|
||||
loader_only: bool,
|
||||
loader_version: Option<String>,
|
||||
version: Option<String>,
|
||||
}
|
||||
|
||||
impl Update {
|
||||
pub fn new(
|
||||
mods_only: bool,
|
||||
loader_only: bool,
|
||||
loader_version: Option<String>,
|
||||
version: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
mods_only,
|
||||
loader_only,
|
||||
loader_version,
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run(&self) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
35
src/main.rs
35
src/main.rs
|
|
@ -2,7 +2,7 @@ mod commands;
|
|||
mod models;
|
||||
mod utils;
|
||||
|
||||
use crate::commands::{create::Create, install::Install, search::Search};
|
||||
use crate::commands::{create::Create, install::Install, search::Search, update::Update};
|
||||
use clap::{
|
||||
Parser, Subcommand,
|
||||
builder::styling::{self},
|
||||
|
|
@ -75,6 +75,25 @@ enum Commands {
|
|||
#[arg(trailing_var_arg = true)]
|
||||
mods: Vec<String>,
|
||||
},
|
||||
|
||||
/// Update minecraft/mods/loader for project in current directory
|
||||
Update {
|
||||
/// Only update mods to latest version for current minecraft version
|
||||
#[arg(long, conflicts_with_all = ["loader_only", "loader_version"])]
|
||||
mods_only: bool,
|
||||
|
||||
/// Only update mod loader to latest version
|
||||
#[arg(long, conflicts_with_all = ["mods_only", "version"])]
|
||||
loader_only: bool,
|
||||
|
||||
/// Specify mod loader version to update to
|
||||
#[arg(long, conflicts_with = "mods_only")]
|
||||
loader_version: Option<String>,
|
||||
|
||||
/// Specify minecraft version to update to
|
||||
#[arg(long, conflicts_with = "loader_only")]
|
||||
version: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -120,6 +139,20 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
let install = Install::new(mods);
|
||||
install.run().await?;
|
||||
}
|
||||
Commands::Update {
|
||||
mods_only,
|
||||
loader_only,
|
||||
loader_version,
|
||||
version,
|
||||
} => {
|
||||
let update = Update::new(
|
||||
mods_only,
|
||||
loader_only,
|
||||
loader_version,
|
||||
version,
|
||||
);
|
||||
update.run().await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue