Skip to content

Commit 2d7fafc

Browse files
committed
style: cargo clippy
1 parent dce1cb5 commit 2d7fafc

File tree

10 files changed

+38
-20
lines changed

10 files changed

+38
-20
lines changed

src/commands/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::PathBuf;
33
use crate::{api::Client, config::Config, solution::Solution};
44
use anyhow::Result;
55

6-
pub fn build(client: Client, config: &mut Config) -> Result<()> {
6+
pub fn build(_client: Client, _config: &mut Config) -> Result<()> {
77
println!("Building project...");
88
let cwd = std::env::current_dir()?;
99
let manifest_paths = manifest_search(&cwd)?;

src/commands/login.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{api::Client, config::Config, utils::progress::*};
22
use anyhow::Result;
3-
use std::time::Duration;
43
use inquire::{validator::ExactLengthValidator, Password, PasswordDisplayMode, Select};
54

65
enum LoginMethod {

src/commands/new.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
use crate::{
22
api::Client,
33
config::Config,
4-
helpers::forge_generator::{self, ForgeGenerator},
5-
utils::{progress::{make_progress, finish_progress}, get_instance_paths, get_game_version},
4+
helpers::forge_generator::ForgeGenerator,
65
structs::Instance,
6+
utils::{
7+
get_game_version, get_instance_paths,
8+
progress::{finish_progress, make_progress},
9+
},
710
};
811
use anyhow::Result;
912
use convert_case::{Case, Casing};
10-
use inquire::{Confirm, MultiSelect, Select, Text, validator::{self, MinLengthValidator, Validation}, CustomUserError};
13+
use inquire::{
14+
validator::{self, MinLengthValidator, Validation},
15+
Confirm, CustomUserError, MultiSelect, Select, Text,
16+
};
1117
use slug::slugify;
1218
use std::path::PathBuf;
1319

@@ -82,7 +88,7 @@ pub fn new(client: Client, _config: &mut Config) -> Result<()> {
8288
.prompt()?;
8389

8490
let instances = get_instance_paths();
85-
let instance = if instances.len() == 0 {
91+
let instance = if instances.is_empty() {
8692
let ipath: PathBuf = Text::new("Could not autodetect Beat Saber install. Please enter the path to your Beat Saber install.")
8793
.with_validator(FileExistsValidatior)
8894
.prompt()?.into();
@@ -92,16 +98,24 @@ pub fn new(client: Client, _config: &mut Config) -> Result<()> {
9298
name: "Custom".into(),
9399
game_version: get_game_version(ipath.to_str().unwrap().to_string()),
94100
}
95-
96101
} else {
97-
Select::new("Which Beat Saber install would you like to build in?", instances).prompt()?
102+
Select::new(
103+
"Which Beat Saber install would you like to build in?",
104+
instances,
105+
)
106+
.prompt()?
98107
};
99108

100109
let pb = make_progress();
101110
pb.set_message(format!("Creating {}...", mod_name_pascal));
102111

103112
let mod_path = std::env::current_dir()?.join(&mod_name_pascal);
104-
ForgeGenerator::new(mod_name_pascal, mod_path.to_str().unwrap().to_string(), instance).generate();
113+
ForgeGenerator::new(
114+
mod_name_pascal,
115+
mod_path.to_str().unwrap().to_string(),
116+
instance,
117+
)
118+
.generate();
105119

106120
finish_progress(&pb, "Done!");
107121

src/commands/publish.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/helpers/forge_generator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//? - checksum, sargon64 - 2023
55

66
use crate::structs::Instance;
7-
use forge_lib::structs::{forgemod, manifest::ForgeManifest, v1::ManifestBuilder};
7+
use forge_lib::structs::v1::ManifestBuilder;
88
use semver::{Version, VersionReq};
99
use uuid::Uuid;
1010

@@ -69,7 +69,8 @@ impl ForgeGenerator {
6969
std::fs::write(
7070
format!("{}/{}/beatforge.manifest", self.path, self.name),
7171
self.make_bf_manifest(),
72-
).unwrap();
72+
)
73+
.unwrap();
7374

7475
std::fs::write(
7576
format!("{}/{}/{}.csproj.user", self.path, self.name, self.name),

src/helpers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub(crate) mod forge_generator;
1+
pub(crate) mod forge_generator;

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ mod api;
22
mod commands;
33
mod config;
44
mod helpers;
5+
mod solution;
56
mod structs;
67
mod utils;
7-
mod solution;
88

9+
use anyhow::{Error, Result};
910
use api::Client;
1011
use clap::{Parser, Subcommand};
11-
use commands::{login::login, new::new, build::build};
12-
use anyhow::{Result, Error};
12+
use commands::{build::build, login::login, new::new};
1313

1414
#[derive(Parser, Debug)]
1515
#[clap(version = env!("CARGO_PKG_VERSION"), author = "BeatForge")]

src/solution.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
// A struct representing a C# solution with build helpers
22

3+
use anyhow::Result;
34
use std::{path::PathBuf, process::Command};
4-
use anyhow::{Result, Error};
55

66
pub struct Solution {
77
pub name: String,
88
pub path: PathBuf,
99
}
1010

1111
impl Solution {
12-
pub fn new<T: Into<String>, U: Into<PathBuf>>(name: T, path: U) -> Solution {
13-
Solution { name: name.into(), path: path.into() }
12+
pub fn new<T: Into<String>, U: Into<PathBuf>>(name: T, path: U) -> Solution {
13+
Solution {
14+
name: name.into(),
15+
path: path.into(),
16+
}
1417
}
1518

1619
pub fn restore(&self) -> Result<()> {

src/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ impl std::fmt::Display for Instance {
4747
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4848
write!(f, "{} ({})", self.name, self.game_version)
4949
}
50-
}
50+
}

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn get_game_version(path: String) -> String {
127127
let mut bytes = Vec::new();
128128
file.read_to_end(&mut bytes).unwrap();
129129

130-
let out = String::from_utf8_lossy(&*bytes);
130+
let out = String::from_utf8_lossy(&bytes);
131131
let pos = out.find("public.app-category.games").unwrap();
132132
let regex = Regex::new(r"[\d]+.[\d]+.[\d]+(p1)?").unwrap();
133133

0 commit comments

Comments
 (0)