Skip to content

Commit 9cd2c2d

Browse files
author
MagicTeaMC
committed
idk
1 parent c8aec72 commit 9cd2c2d

14 files changed

Lines changed: 79 additions & 56 deletions

File tree

src/cli/commands/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
pub mod plugins;
12
pub mod setup;
23
pub mod sync;
34
pub mod upgrade;
4-
pub mod plugins;
55

6+
pub use plugins::handle_plugins;
67
pub use setup::handle_setup;
78
pub use sync::handle_sync;
89
pub use upgrade::handle_upgrade;
9-
pub use plugins::handle_plugins;

src/cli/commands/plugins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use anyhow::Result;
21
use crate::cli::PluginActions;
32
use crate::plugins;
3+
use anyhow::Result;
44

55
pub async fn handle_plugins(action: PluginActions) -> Result<()> {
66
match action {

src/cli/commands/setup.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
use std::{io::Write, process::exit};
1+
use anyhow::Result;
22
use colored::Colorize;
33
use inquire::{Confirm, Select, Text};
4-
use anyhow::Result;
4+
use std::{io::Write, process::exit};
55

66
use crate::core::{Config, Software, eula};
77
use crate::download;
8-
use crate::utils::{get_current_directory_name, get_executable_extension, inquired, print_error_and_exit};
8+
use crate::utils::{
9+
get_current_directory_name, get_executable_extension, inquired, print_error_and_exit,
10+
};
911

1012
pub async fn handle_setup(
1113
software: Option<Software>,

src/cli/commands/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use std::{io::Write, process::exit};
2-
use colored::Colorize;
31
use anyhow::Result;
2+
use colored::Colorize;
3+
use std::{io::Write, process::exit};
44

55
use crate::core::Config;
66
use crate::download;

src/cli/commands/upgrade.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use std::{io::Write, process::exit};
1+
use anyhow::Result;
22
use colored::Colorize;
33
use inquire::Text;
4-
use anyhow::Result;
4+
use std::{io::Write, process::exit};
55

66
use crate::core::Config;
77
use crate::download;

src/core/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::core::software::Software;
2+
use anyhow::Result;
23
use serde::{Deserialize, Serialize};
34
use std::{fs, path::Path};
4-
use anyhow::Result;
55

66
const CONFIG_FILE: &str = "mcsast.config.json";
77

@@ -27,7 +27,9 @@ pub struct Config {
2727
impl Config {
2828
pub fn load() -> Result<Self> {
2929
if !Path::new(CONFIG_FILE).exists() {
30-
return Err(anyhow::anyhow!("No config file found. Please run 'mcsast setup' first."));
30+
return Err(anyhow::anyhow!(
31+
"No config file found. Please run 'mcsast setup' first."
32+
));
3133
}
3234

3335
let content = fs::read_to_string(CONFIG_FILE)?;

src/core/eula.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::{fs, io::Write};
21
use anyhow::Result;
2+
use std::{fs, io::Write};
33

44
pub fn add_eula() -> Result<()> {
55
let mut file = fs::File::create("eula.txt")?;

src/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod config;
2-
pub mod software;
32
pub mod eula;
3+
pub mod software;
44

55
pub use config::{Config, PluginConfig};
66
pub use software::Software;

src/download/downloader.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
use tokio::fs;
21
use anyhow::Result;
2+
use tokio::fs;
33

44
async fn download_jar(res: reqwest::Response) -> Result<()> {
55
let bytes = res.bytes().await?;
66
fs::write("server.jar", &bytes).await?;
77
Ok(())
88
}
99

10-
async fn download_binary(
11-
res: reqwest::Response,
12-
filename: &str,
13-
) -> Result<()> {
10+
async fn download_binary(res: reqwest::Response, filename: &str) -> Result<()> {
1411
let bytes = res.bytes().await?;
1512
fs::write(filename, &bytes).await?;
1613

@@ -59,7 +56,10 @@ pub async fn get_geyser(_version: String) -> Result<()> {
5956
download_jar(res).await?;
6057
Ok(())
6158
} else {
62-
Err(anyhow::anyhow!("Failed to download Geyser: HTTP {}", res.status()))
59+
Err(anyhow::anyhow!(
60+
"Failed to download Geyser: HTTP {}",
61+
res.status()
62+
))
6363
}
6464
}
6565

@@ -75,7 +75,10 @@ pub async fn get_nukkit(_version: String) -> Result<()> {
7575
download_jar(res).await?;
7676
Ok(())
7777
} else {
78-
Err(anyhow::anyhow!("Failed to download Nukkit: HTTP {}", res.status()))
78+
Err(anyhow::anyhow!(
79+
"Failed to download Nukkit: HTTP {}",
80+
res.status()
81+
))
7982
}
8083
}
8184

@@ -107,7 +110,10 @@ pub async fn get_gate(_version: String) -> Result<()> {
107110
download_binary(res, &filename).await?;
108111
Ok(())
109112
} else {
110-
Err(anyhow::anyhow!("Failed to download Gate: HTTP {}", res.status()))
113+
Err(anyhow::anyhow!(
114+
"Failed to download Gate: HTTP {}",
115+
res.status()
116+
))
111117
}
112118
}
113119

@@ -150,7 +156,8 @@ pub async fn get_other(software: String, version: String) -> Result<()> {
150156
if res.status() == 404 {
151157
return Err(anyhow::anyhow!(
152158
"Version {} not found for {}. Please check if this version exists.",
153-
version, software
159+
version,
160+
software
154161
));
155162
} else {
156163
return Err(anyhow::anyhow!(

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub mod cli;
22
pub mod core;
3-
pub mod plugins;
43
pub mod download;
4+
pub mod plugins;
55
pub mod utils;
66

77
pub use cli::CLI;

0 commit comments

Comments
 (0)