Skip to content

Commit 2980a3f

Browse files
committed
run cargo fmt and fix most clippy warnings
the code before had a horrible mix of spaces and tabs everywhere, even on the same line!!!! so now use tabs for everything since that seemed to be the dominant indentation style also change some of the code as suggested by clippy
1 parent 3de365e commit 2980a3f

18 files changed

+845
-659
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "geode"
3-
version = "1.0.6"
3+
version = "1.0.7"
44
authors = ["HJfod <[email protected]>", "Camila314 <[email protected]>"]
55
edition = "2021"
66
build = "build.rs"

build.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#[cfg(windows)] extern crate winres;
1+
#[cfg(windows)]
2+
extern crate winres;
3+
24
fn main() {
3-
#[cfg(windows)] {
4-
let mut res = winres::WindowsResource::new();
5-
res.set_icon("geode.ico");
6-
res.compile().unwrap();
7-
}
5+
#[cfg(windows)]
6+
{
7+
let mut res = winres::WindowsResource::new();
8+
res.set_icon("geode.ico");
9+
res.compile().unwrap();
10+
}
811
}

rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hard_tabs = true

src/info.rs

+38-40
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use std::cell::RefCell;
2-
use std::io::BufRead;
3-
/**
4-
* geode info
5-
*/
6-
use std::path::{PathBuf};
71
use crate::config::Config;
82
use crate::util::config::Profile;
9-
use crate::{fail, done, info};
103
use crate::NiceUnwrap;
11-
use colored::Colorize;
4+
use crate::{done, fail, info};
125
use clap::Subcommand;
6+
use colored::Colorize;
7+
use std::cell::RefCell;
8+
use std::io::BufRead;
9+
/**
10+
* geode info
11+
*/
12+
use std::path::PathBuf;
1313

1414
#[derive(Subcommand, Debug)]
1515
pub enum Info {
@@ -19,7 +19,7 @@ pub enum Info {
1919
field: String,
2020

2121
/// New value
22-
value: String
22+
value: String,
2323
},
2424

2525
/// Get value
@@ -29,21 +29,17 @@ pub enum Info {
2929

3030
/// Output raw value
3131
#[clap(long)]
32-
raw: bool
32+
raw: bool,
3333
},
34-
34+
3535
/// List possible values
3636
List,
3737

3838
/// Setup config (if you have manually installed Geode)
3939
Setup {},
4040
}
4141

42-
const CONFIGURABLES: [&str; 3] = [
43-
"default-developer",
44-
"sdk-path",
45-
"sdk-nightly"
46-
];
42+
const CONFIGURABLES: [&str; 3] = ["default-developer", "sdk-path", "sdk-nightly"];
4743

4844
fn get_bool(value: &str) -> Option<bool> {
4945
let lower = value.to_ascii_lowercase();
@@ -65,15 +61,15 @@ pub fn subcommand(config: &mut Config, cmd: Info) {
6561
if field == "default-developer" {
6662
config.default_developer = Some(value);
6763
} else if field == "sdk-nightly" {
68-
config.sdk_nightly = get_bool(&value)
69-
.nice_unwrap(format!("'{}' cannot be parsed as a bool", value));
64+
config.sdk_nightly =
65+
get_bool(&value).nice_unwrap(format!("'{}' cannot be parsed as a bool", value));
7066
} else {
7167
fail!("Unknown field {}", field);
7268
return;
7369
}
7470

7571
done!("{}", done_str);
76-
},
72+
}
7773

7874
Info::Get { field, raw } => {
7975
let sdk_path;
@@ -89,42 +85,40 @@ pub fn subcommand(config: &mut Config, cmd: Info) {
8985
} else {
9086
"false"
9187
}
88+
} else if raw {
89+
std::process::exit(1);
9290
} else {
93-
if raw {
94-
std::process::exit(1);
95-
} else {
96-
fail!("Unknown field {}", field);
97-
return;
98-
}
91+
fail!("Unknown field {}", field);
92+
return;
9993
};
10094

10195
if raw {
10296
print!("{}", out);
10397
} else {
10498
println!("{} = {}", field.bright_cyan(), out.bright_green());
10599
}
106-
},
100+
}
107101

108102
Info::List => {
109103
for i in CONFIGURABLES {
110104
println!("{}", i);
111105
}
112-
},
106+
}
113107

114108
Info::Setup {} => {
115109
if config.profiles.is_empty() {
116110
info!("Please enter the path to the Geometry Dash folder:");
117-
111+
118112
let path = loop {
119113
let mut buf = String::new();
120114
match std::io::stdin().lock().read_line(&mut buf) {
121-
Ok(_) => {},
115+
Ok(_) => {}
122116
Err(e) => {
123117
fail!("Unable to read input: {}", e);
124118
continue;
125119
}
126120
};
127-
121+
128122
// Verify path is valid
129123
let path = PathBuf::from(buf.trim());
130124
if !path.is_dir() {
@@ -134,11 +128,15 @@ pub fn subcommand(config: &mut Config, cmd: Info) {
134128
);
135129
continue;
136130
}
137-
if path.read_dir().map(|mut files| files.next().is_none()).unwrap_or(false) {
131+
if path
132+
.read_dir()
133+
.map(|mut files| files.next().is_none())
134+
.unwrap_or(false)
135+
{
138136
fail!("Given path appears to be empty");
139137
continue;
140138
}
141-
// todo: maybe do some checksum verification
139+
// todo: maybe do some checksum verification
142140
// to make sure GD 2.113 is in the folder
143141
break path;
144142
};
@@ -148,20 +146,20 @@ pub fn subcommand(config: &mut Config, cmd: Info) {
148146
let mut buf = String::new();
149147
match std::io::stdin().lock().read_line(&mut buf) {
150148
Ok(_) => break buf,
151-
Err(e) => fail!("Unable to read input: {}", e)
149+
Err(e) => fail!("Unable to read input: {}", e),
152150
};
153151
};
154-
155-
config.profiles.push(RefCell::new(
156-
Profile::new(name.trim().into(), path)
157-
));
152+
153+
config
154+
.profiles
155+
.push(RefCell::new(Profile::new(name.trim().into(), path)));
158156
config.current_profile = Some(name.trim().into());
159157
done!("Profile added");
160158
}
161159

162160
config.sdk_nightly = Config::sdk_path().join("bin/nightly").exists();
163-
161+
164162
done!("Config setup finished");
165-
},
163+
}
166164
}
167-
}
165+
}

src/main.rs

+58-59
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use clap::{Parser, Subcommand};
12
/**
23
* geode new: Create new geode project from template
34
* geode info: Subcommand for listing information about the current state
@@ -7,88 +8,86 @@
78
* geode install: alias of `geode package install`
89
*/
910
use std::path::PathBuf;
10-
use clap::{Parser, Subcommand};
1111

12-
mod util;
13-
mod template;
12+
mod info;
1413
mod package;
1514
mod profile;
16-
mod info;
1715
mod sdk;
16+
mod template;
17+
mod util;
1818

1919
use util::*;
2020

2121
/// Command-line interface for Geode
2222
#[derive(Parser, Debug)]
2323
#[clap(version)]
2424
struct Args {
25-
#[clap(subcommand)]
26-
command: GeodeCommands
25+
#[clap(subcommand)]
26+
command: GeodeCommands,
2727
}
2828

2929
#[derive(Subcommand, Debug)]
3030
enum GeodeCommands {
31-
/// Create template mod project
32-
New {
33-
/// Mod project directory
34-
#[clap(short, long)]
35-
path: Option<PathBuf>,
36-
37-
/// Mod name
38-
#[clap(short, long)]
39-
name: Option<String>
40-
},
41-
42-
/// Install a .geode package to current profile, alias of `geode package install`
43-
Install {
44-
/// Location of the .geode package to install
45-
path: PathBuf
46-
},
47-
48-
/// Subcommand for managing profiles
49-
Profile {
50-
#[clap(subcommand)]
51-
commands: crate::profile::Profile
52-
},
53-
54-
/// Subcommand for managing configurable data
55-
Config {
56-
#[clap(subcommand)]
57-
commands: crate::info::Info
58-
},
59-
60-
/// Subcommand for managing the Geode SDK
61-
Sdk {
62-
#[clap(subcommand)]
63-
commands: crate::sdk::Sdk
64-
},
65-
66-
/// Subcommand for managing Geode packages
67-
Package {
68-
#[clap(subcommand)]
69-
commands: crate::package::Package
70-
}
31+
/// Create template mod project
32+
New {
33+
/// Mod project directory
34+
#[clap(short, long)]
35+
path: Option<PathBuf>,
36+
37+
/// Mod name
38+
#[clap(short, long)]
39+
name: Option<String>,
40+
},
41+
42+
/// Install a .geode package to current profile, alias of `geode package install`
43+
Install {
44+
/// Location of the .geode package to install
45+
path: PathBuf,
46+
},
47+
48+
/// Subcommand for managing profiles
49+
Profile {
50+
#[clap(subcommand)]
51+
commands: crate::profile::Profile,
52+
},
53+
54+
/// Subcommand for managing configurable data
55+
Config {
56+
#[clap(subcommand)]
57+
commands: crate::info::Info,
58+
},
59+
60+
/// Subcommand for managing the Geode SDK
61+
Sdk {
62+
#[clap(subcommand)]
63+
commands: crate::sdk::Sdk,
64+
},
65+
66+
/// Subcommand for managing Geode packages
67+
Package {
68+
#[clap(subcommand)]
69+
commands: crate::package::Package,
70+
},
7171
}
7272

73-
7473
fn main() {
75-
let args = Args::parse();
74+
let args = Args::parse();
75+
76+
let mut config = config::Config::new();
7677

77-
let mut config = config::Config::new();
78+
match args.command {
79+
GeodeCommands::New { name, path } => template::build_template(&mut config, name, path),
7880

79-
match args.command {
80-
GeodeCommands::New { name, path} => template::build_template(&mut config, name, path),
81-
82-
GeodeCommands::Install { path } => package::install(&mut config, &path),
81+
GeodeCommands::Install { path } => package::install(&mut config, &path),
8382

84-
GeodeCommands::Profile { commands } => profile::subcommand(&mut config, commands),
83+
GeodeCommands::Profile { commands } => profile::subcommand(&mut config, commands),
8584

86-
GeodeCommands::Config { commands } => info::subcommand(&mut config, commands),
85+
GeodeCommands::Config { commands } => info::subcommand(&mut config, commands),
8786

88-
GeodeCommands::Sdk { commands } => sdk::subcommand(&mut config, commands),
87+
GeodeCommands::Sdk { commands } => sdk::subcommand(&mut config, commands),
8988

90-
GeodeCommands::Package { commands } => package::subcommand(&mut config, commands),
91-
}
89+
GeodeCommands::Package { commands } => package::subcommand(&mut config, commands),
90+
}
9291

93-
config.save();
92+
config.save();
9493
}

0 commit comments

Comments
 (0)