add clean command
This commit is contained in:
parent
8939d1195d
commit
4fe35b4b60
24
mpt/src/commands/clean.rs
Normal file
24
mpt/src/commands/clean.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
use crate::{config::Config, util::CliStyle};
|
||||||
|
|
||||||
|
pub async fn run(config: Config) -> anyhow::Result<()> {
|
||||||
|
// These operations are so incredibly performance-critical that we absolutely
|
||||||
|
// must execute them in parallel!
|
||||||
|
let (res1, res2) = tokio::join!(
|
||||||
|
async {
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
format!("Deleting {}", config.locations.temp_dir.to_string_lossy()).info(),
|
||||||
|
);
|
||||||
|
tokio::fs::remove_dir_all(config.locations.temp_dir).await
|
||||||
|
},
|
||||||
|
async {
|
||||||
|
println!("{}", "Deleting build".info(),);
|
||||||
|
tokio::fs::remove_dir_all("build").await
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
res1?;
|
||||||
|
res2?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
pub mod buildtwitch;
|
pub mod buildtwitch;
|
||||||
|
pub mod clean;
|
||||||
pub mod downloadmods;
|
pub mod downloadmods;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct Opt {
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
enum Command {
|
enum Command {
|
||||||
|
#[structopt(help = "Initializes a new modpack")]
|
||||||
Init {
|
Init {
|
||||||
#[structopt(help = "The name of the modpack")]
|
#[structopt(help = "The name of the modpack")]
|
||||||
modpack_name: String,
|
modpack_name: String,
|
||||||
|
@ -24,7 +25,7 @@ enum Command {
|
||||||
mcversion: String,
|
mcversion: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[structopt(name = "downloadmods")]
|
#[structopt(name = "downloadmods", help = "Downloads mods of the pack")]
|
||||||
DownloadMods {
|
DownloadMods {
|
||||||
#[structopt(help = "Directory to download mods to")]
|
#[structopt(help = "Directory to download mods to")]
|
||||||
dir: PathBuf,
|
dir: PathBuf,
|
||||||
|
@ -32,7 +33,7 @@ enum Command {
|
||||||
all: bool,
|
all: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[structopt(name = "buildtwitch")]
|
#[structopt(name = "buildtwitch", help = "Builds a twitch export of the pack")]
|
||||||
BuildTwitch {
|
BuildTwitch {
|
||||||
#[structopt(
|
#[structopt(
|
||||||
short,
|
short,
|
||||||
|
@ -41,6 +42,9 @@ enum Command {
|
||||||
)]
|
)]
|
||||||
all: bool,
|
all: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
#[structopt(help = "Deletes artifacts and temporary files")]
|
||||||
|
Clean,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -61,6 +65,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
Command::BuildTwitch { all } => {
|
Command::BuildTwitch { all } => {
|
||||||
commands::buildtwitch::run(util::parse_config_and_manifest().await?, all).await?
|
commands::buildtwitch::run(util::parse_config_and_manifest().await?, all).await?
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Command::Clean => commands::clean::run(util::parse_config().await?).await?,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue