Skip to content

Commit

Permalink
mrpack export, packwiz import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Jul 27, 2023
1 parent f1e1818 commit a750826
Show file tree
Hide file tree
Showing 31 changed files with 1,929 additions and 337 deletions.
92 changes: 3 additions & 89 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mcman"
version = "0.2.1"
version = "0.3.0"
edition = "2021"
authors = ["ParadigmMC"]
repository = "https://github.com/ParadigmMC/mcman"
Expand Down Expand Up @@ -31,7 +31,6 @@ serde_json = "1.0"
tempfile = "3.7"
tokio = { version = "1.29", features = ["macros", "rt", "rt-multi-thread"] }
toml = "0.7"
tracing = "0.1"
tracing-subscriber = "0.3"
walkdir = "2.3"
zip = "0.6"
sha2 = "0.10"
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ Submit a PR or open an issue if you have a mcman-server repository that we can a

## Changelog

### `0.2.2` (unreleased)
### `0.3.0` (unreleased)

- Added [CurseRinth](https://curserinth.kuylar.dev/) support
- Added **packwiz importing**
- Added **packwiz exporting**
- Added initializing with `--packwiz`
- Added **mrpack exporting**
- Added client-side mods field
- Fixed github ratelimiting issue
- A lot of improvements overall

### `0.2.2`

- Added support for **Datapacks**
- Added command `mcman import datapack`
Expand Down
11 changes: 11 additions & 0 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
- [Github Releases](https://github.com/ParadigmMC/mcman/releases)
- [build action](https://github.com/ParadigmMC/mcman/actions/workflows/build.yml) (requires github account)

### Windows: Scoop

[Scoop](https://scoop.sh/) is a command-line installer for Windows. You can use 2 commands in powershell to install it.

Add the [minecraft](https://github.com/The-Simples/scoop-minecraft) bucket and install mcman:

```powershell
scoop bucket add minecraft https://github.com/The-Simples/scoop-minecraft
scoop install mcman
```

## Recommended Usage

First, initialize a github repository for your server and clone it. It can be private too if you want.
Expand Down
10 changes: 9 additions & 1 deletion res/default_gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# mcman
# generated by mcman

# exclude server output directory
server/

# dont include the dotenv
.env

# exclude exported packs
*.zip
*.mrpack
6 changes: 4 additions & 2 deletions src/commands/build/addons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ impl BuildContext {
self.downloadable(addon, Some(addon_type), |state, file_name| match state {
ReportBackState::Skipped => {
println!(
" ({idx:idx_w$}/{addon_count}) Skipping : {}",
" ({:idx_w$}/{addon_count}) Skipping : {}",
idx + 1,
style(&file_name).dim()
);
}
ReportBackState::Downloaded => {
println!(
" ({idx:idx_w$}/{addon_count}) {} : {}",
" ({:idx_w$}/{addon_count}) {} : {}",
idx + 1,
style("Downloaded").green().bold(),
style(&file_name).dim()
);
Expand Down
40 changes: 26 additions & 14 deletions src/commands/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{path::PathBuf, time::Instant};
use anyhow::{anyhow, Context, Result};
use clap::{arg, value_parser, ArgMatches, Command};
use console::style;
use tokio::fs::File;
use tokio::fs::{File, self};

use crate::{create_http_client, downloadable::Downloadable, model::Server, util};

Expand Down Expand Up @@ -139,7 +139,8 @@ impl BuildContext {
folder_path: Option<&str>,
report_back: F,
) -> Result<String> {
let file_name = dl.get_filename(&self.server, &self.http_client).await?;
let file_name = dl.get_filename(&self.server, &self.http_client)
.await.with_context(|| format!("Getting filename of Downloadable: {dl:#?}"))?;

let file_path = if let Some(path) = folder_path {
self.output_dir.join(path)
Expand All @@ -153,18 +154,29 @@ impl BuildContext {
} else {
report_back(ReportBackState::Downloading, &file_name);

util::download_with_progress(
File::create(&file_path).await.context(format!(
"Failed to create output file: {}",
file_path.to_string_lossy()
))?,
&file_name,
dl,
Some(&file_name),
&self.server,
&self.http_client,
)
.await?;
let file = File::create(&file_path).await.with_context(|| format!(
"Failed to create output file: {}",
file_path.to_string_lossy()
))?;

let result = util::download_with_progress(
file,
&file_name,
dl,
Some(&file_name),
&self.server,
&self.http_client,
)
.await
.with_context(|| format!("Downloading Downloadable: {dl:#?}"));

if result.is_err() {
// try to remove file if errored
// so we wont have any "0 bytes" files (which mcman will skip)
_ = fs::remove_file(file_path).await;
}

result?;

report_back(ReportBackState::Downloaded, &file_name);
}
Expand Down
9 changes: 6 additions & 3 deletions src/commands/build/worlds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ impl BuildContext {

for (idx, (name, world)) in self.server.worlds.iter().enumerate() {
println!(
" ({idx:wc_len$}/{world_count}) {} {name}",
" ({:wc_len$}/{world_count}) {} {name}",
idx + 1,
style("World:").bold()
);

Expand All @@ -30,14 +31,16 @@ impl BuildContext {
match state {
ReportBackState::Skipped => {
println!(
" {:pad_len$}({idx:dp_len$}/{datapack_count}) Skipping : {}",
" {:pad_len$}({:dp_len$}/{datapack_count}) Skipping : {}",
idx + 1,
"",
style(file_name).dim()
);
}
ReportBackState::Downloaded => {
println!(
" {:pad_len$}({idx:dp_len$}/{datapack_count}) {} : {}",
" {:pad_len$}({:dp_len$}/{datapack_count}) {} : {}",
idx + 1,
"",
style("Downloaded").green().bold(),
style(file_name).dim()
Expand Down
35 changes: 35 additions & 0 deletions src/commands/eject.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::fs;

use anyhow::{Result, Context};
use clap::Command;
use console::style;
use dialoguer::{Input, theme::ColorfulTheme};

use crate::model::Server;

pub fn cli() -> Command {
Command::new("eject")
.hide(true)
.about("Eject - remove everything related to mcman")
}

pub async fn run() -> Result<()> {
let server = Server::load().context("Failed to load server.toml")?;

if Input::with_theme(&ColorfulTheme::default())
.with_prompt("Are you sure you want to delete everything? This is irreversible. Type this server's name to confirm.")
.default(String::new())
.interact_text()? == server.name {
println!(" > {}", style("Deleting server.toml...").yellow());
_ = fs::remove_file(server.path.join("server.toml"))?;

Check failure on line 24 in src/commands/eject.rs

View workflow job for this annotation

GitHub Actions / clippy

this let-binding has unit value

error: this let-binding has unit value --> src/commands/eject.rs:24:9 | 24 | _ = fs::remove_file(server.path.join("server.toml"))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `fs::remove_file(server.path.join("server.toml"))?;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value = note: `#[deny(clippy::let_unit_value)]` implied by `#[deny(clippy::all)]`
println!(" > {}", style("Deleting config/...").yellow());
_ = fs::remove_dir_all(server.path.join("config"));
println!(" > {}", style("Deleting server/...").yellow());
_ = fs::remove_dir_all(server.path.join("server"))?;

Check failure on line 28 in src/commands/eject.rs

View workflow job for this annotation

GitHub Actions / clippy

this let-binding has unit value

error: this let-binding has unit value --> src/commands/eject.rs:28:9 | 28 | _ = fs::remove_dir_all(server.path.join("server"))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `fs::remove_dir_all(server.path.join("server"))?;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
println!(" > Ejected successfully.");
} else {
println!(" > {}", style("Cancelled").green().bold());
}

Ok(())
}

Check warning on line 35 in src/commands/eject.rs

View workflow job for this annotation

GitHub Actions / clippy

unused `async` for function with no await statements

warning: unused `async` for function with no await statements --> src/commands/eject.rs:16:1 | 16 | / pub async fn run() -> Result<()> { 17 | | let server = Server::load().context("Failed to load server.toml")?; 18 | | 19 | | if Input::with_theme(&ColorfulTheme::default()) ... | 34 | | Ok(()) 35 | | } | |_^ | = help: consider removing the `async` from this function = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_async note: the lint level is defined here --> src/main.rs:2:9 | 2 | #![warn(clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(clippy::unused_async)]` implied by `#[warn(clippy::pedantic)]`
Loading

0 comments on commit a750826

Please sign in to comment.