Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Dec 12, 2023
1 parent aa12f78 commit 02d4b98
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 95 deletions.
8 changes: 6 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use feedback::*;
use indicatif::MultiProgress;
pub use resolvable::*;

use crate::model::{Network, Server, Downloadable, AppConfig};
use crate::model::{AppConfig, Downloadable, Network, Server};
use crate::sources;

pub const APP_USER_AGENT: &str = concat!(
Expand Down Expand Up @@ -94,7 +94,11 @@ impl App {
config: Config::builder()
.env()
.file(".mcman.toml")
.file(dirs::config_dir().unwrap_or_default().join("mcman/.mcman.toml"))
.file(
dirs::config_dir()
.unwrap_or_default()
.join("mcman/.mcman.toml"),
)
.load()?,
})
}
Expand Down
12 changes: 9 additions & 3 deletions src/commands/add/modrinth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{bail, Result, Context};
use anyhow::{bail, Context, Result};

use crate::{
app::{App, Prefix},
Expand Down Expand Up @@ -27,7 +27,10 @@ pub async fn run(mut app: App, args: Args) -> Result<()> {
app.prompt_string("Search on Modrinth")?
};

let projects = app.modrinth().search(&query).await
let projects = app
.modrinth()
.search(&query)
.await
.context("Searching modrinth")?;

if projects.is_empty() {
Expand All @@ -53,7 +56,10 @@ pub async fn run(mut app: App, args: Args) -> Result<()> {

let project = app.select("Which project?", &items)?;

let versions = app.modrinth().fetch_versions(&project.slug).await
let versions = app
.modrinth()
.fetch_versions(&project.slug)
.await
.context("Fetching modrinth versions")?;

let version = app.select(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/export/packwiz.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::PathBuf, fs};
use std::{fs, path::PathBuf};

use anyhow::Result;

Expand Down
7 changes: 2 additions & 5 deletions src/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ pub struct Args {

pub async fn run(base_app: BaseApp, args: Args) -> Result<()> {
if args.plain {
println!(
"{}",
env!("CARGO_PKG_VERSION")
);
println!("{}", env!("CARGO_PKG_VERSION"));
} else {
println!(
" > {} by {}",
Expand Down Expand Up @@ -64,6 +61,6 @@ pub async fn run(base_app: BaseApp, args: Args) -> Result<()> {
}
}
}

Ok(())
}
2 changes: 1 addition & 1 deletion src/core/addons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::BuildContext;
impl<'a> BuildContext<'a> {
pub async fn download_addons(&mut self, addon_type: AddonType) -> Result<()> {
let server_list = self.app.get_addons(addon_type);

self.app.print_job(&format!(
"Processing {} {addon_type}{}...{}",
server_list.len(),
Expand Down
5 changes: 2 additions & 3 deletions src/hot_reload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use notify_debouncer_mini::{
use pathdiff::diff_paths;
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines},
process::{Child, ChildStdout, ChildStdin},
process::{Child, ChildStdin, ChildStdout},
sync::mpsc,
};

Expand Down Expand Up @@ -124,8 +124,7 @@ impl<'a> DevSession<'a> {
let mp = self.builder.app.multi_progress.clone();

let mut child: Option<Child> = None;
let mut stdout_lines: Option<Lines<BufReader<ChildStdout>>> =
None;
let mut stdout_lines: Option<Lines<BufReader<ChildStdout>>> = None;
let mut child_stdin: Option<ChildStdin> = None;

let mut is_stopping = false;
Expand Down
14 changes: 10 additions & 4 deletions src/interop/markdown.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs::File, io::Write, time::Duration};

use anyhow::{Result, Context};
use anyhow::{Context, Result};
use indexmap::IndexMap;
use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
use regex::Regex;
Expand Down Expand Up @@ -215,8 +215,12 @@ impl<'a> MarkdownAPI<'a> {
.progress_with(pb.clone())
{
pb.set_message(addon.to_string());
table.add_from_map(&self.fetch_downloadable_info(addon).await
.context(format!("Rendering addon: {addon:#?}"))?);
table.add_from_map(
&self
.fetch_downloadable_info(addon)
.await
.context(format!("Rendering addon: {addon:#?}"))?,
);
}

Ok(table)
Expand Down Expand Up @@ -340,7 +344,9 @@ impl<'a> MarkdownAPI<'a> {
])
}

Downloadable::Maven { version, artifact, .. } => IndexMap::from([
Downloadable::Maven {
version, artifact, ..
} => IndexMap::from([
("Name".to_owned(), artifact.clone()),
("Description".to_owned(), dl.get_md_link()),
("Version".to_owned(), version.clone()),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum Commands {
/// Pack or unpack a world
#[command(subcommand, visible_alias = "w")]
World(commands::world::Commands),

/// Importing tools
#[command(subcommand, visible_alias = "i")]
Import(commands::import::Commands),
Expand Down
2 changes: 1 addition & 1 deletion src/model/app_config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use confique::Config;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Config)]
pub struct MCLogsService {
Expand Down
6 changes: 5 additions & 1 deletion src/model/downloadable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ impl Resolvable for Downloadable {
job,
build,
artifact,
} => app.jenkins().resolve_source(url, job, build, artifact).await,
} => {
app.jenkins()
.resolve_source(url, job, build, artifact)
.await
}
Self::Maven {
url,
group,
Expand Down
4 changes: 2 additions & 2 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod app_config;
mod clientsidemod;
mod downloadable;
mod lockfile;
Expand All @@ -6,8 +7,8 @@ mod serverlauncher;
mod servertoml;
mod servertype;
mod world;
mod app_config;

pub use app_config::*;
pub use clientsidemod::*;
pub use downloadable::*;
pub use lockfile::*;
Expand All @@ -16,4 +17,3 @@ pub use serverlauncher::*;
pub use servertoml::*;
pub use servertype::*;
pub use world::*;
pub use app_config::*;
3 changes: 2 additions & 1 deletion src/model/servertype/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::app::{App, Resolvable, ResolvedFile};
use anyhow::Result;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};use crate::app::{App, Resolvable, ResolvedFile};
use serde::{Deserialize, Serialize};

use crate::model::Downloadable;

Expand Down
7 changes: 5 additions & 2 deletions src/sources/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ impl<'a> GithubAPI<'a> {
} else {
None
};

let mut headers = HeaderMap::new();
if let Some(cached_data) = &cached_data {
headers.insert("if-none-match", HeaderValue::from_str(&cached_data.etag)?);
}
headers.insert("X-GitHub-Api-Version", HeaderValue::from_str(GITHUB_API_VERSION)?);
headers.insert(
"X-GitHub-Api-Version",
HeaderValue::from_str(GITHUB_API_VERSION)?,
);

let response = self
.0
Expand Down
Loading

0 comments on commit 02d4b98

Please sign in to comment.