Apply rustfmt pass across all modules

Pure whitespace normalization — no logic changes. Mostly:
- collapsing multi-line match/if arms rustfmt prefers inline
- inlining short `with_context`/`ok_or_else` closures
- reformatting nested method chains for consistency

Build and clippy stay clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-04-17 21:35:27 -07:00
parent e72ee69c14
commit 1bacf345f0
7 changed files with 83 additions and 119 deletions
+15 -39
View File
@@ -104,8 +104,7 @@ fn regex_escape(s: &str) -> String {
for c in s.chars() {
if matches!(
c,
'.' | '*' | '?' | '+' | '(' | ')' | '[' | ']'
| '{' | '}' | '|' | '\\' | '^' | '$'
'.' | '*' | '?' | '+' | '(' | ')' | '[' | ']' | '{' | '}' | '|' | '\\' | '^' | '$'
) {
out.push('\\');
}
@@ -237,9 +236,8 @@ impl Config {
}
Err(e) => {
let bak = path.with_extension("toml.bak");
std::fs::rename(&path, &bak).with_context(|| {
format!("Failed to back up stale config to {bak:?}")
})?;
std::fs::rename(&path, &bak)
.with_context(|| format!("Failed to back up stale config to {bak:?}"))?;
eprintln!("warning: couldn't parse {}: {e}", path.display());
eprintln!(
" backed up to {} — writing fresh config with presets",
@@ -305,8 +303,7 @@ impl Config {
anyhow::bail!("launcher '{name}' already exists");
}
let display = display.unwrap_or_else(|| name.clone());
let prefix_dir = prefix_dir
.unwrap_or_else(|| home_dir().join("Games").join(&name));
let prefix_dir = prefix_dir.unwrap_or_else(|| home_dir().join("Games").join(&name));
let gameid = gameid.unwrap_or_else(|| format!("umu-{name}"));
let process_pattern = process_pattern.unwrap_or_else(|| {
exe_path
@@ -346,13 +343,9 @@ impl Config {
.launchers
.iter_mut()
.find(|l| l.name == launcher)
.ok_or_else(|| {
anyhow::anyhow!("no launcher named '{launcher}'")
})?;
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
if l.games.iter().any(|g| g.name == name) {
anyhow::bail!(
"launcher '{launcher}' already has a game named '{name}'"
);
anyhow::bail!("launcher '{launcher}' already has a game named '{name}'");
}
let display = display.unwrap_or_else(|| name.clone());
l.games.push(Game {
@@ -365,9 +358,7 @@ impl Config {
gamescope,
});
self.save()?;
println!(
"\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'."
);
println!("\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'.");
Ok(())
}
@@ -376,15 +367,11 @@ impl Config {
.launchers
.iter_mut()
.find(|l| l.name == launcher)
.ok_or_else(|| {
anyhow::anyhow!("no launcher named '{launcher}'")
})?;
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
let before = l.games.len();
l.games.retain(|g| g.name != name);
if l.games.len() == before {
anyhow::bail!(
"launcher '{launcher}' has no game named '{name}'"
);
anyhow::bail!("launcher '{launcher}' has no game named '{name}'");
}
self.save()?;
println!("\x1b[1;32m✓\x1b[0m Removed game '{name}' from '{launcher}'.");
@@ -410,17 +397,10 @@ impl Config {
.launchers
.iter_mut()
.find(|l| l.name == launcher)
.ok_or_else(|| {
anyhow::anyhow!("no launcher named '{launcher}'")
})?;
let g = l
.games
.iter_mut()
.find(|g| g.name == name)
.ok_or_else(|| {
anyhow::anyhow!(
"launcher '{launcher}' has no game named '{name}'"
)
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
let g =
l.games.iter_mut().find(|g| g.name == name).ok_or_else(|| {
anyhow::anyhow!("launcher '{launcher}' has no game named '{name}'")
})?;
if let Some(v) = gamemode {
g.gamemode = v;
@@ -432,9 +412,7 @@ impl Config {
g.gamescope = v;
}
self.save()?;
println!(
"\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'."
);
println!("\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'.");
Ok(())
}
@@ -460,9 +438,7 @@ impl Config {
compat_dir: Option<PathBuf>,
) -> Result<()> {
if proton_version.is_none() && compat_dir.is_none() {
anyhow::bail!(
"nothing to set — pass --proton-version or --compat-dir"
);
anyhow::bail!("nothing to set — pass --proton-version or --compat-dir");
}
if let Some(v) = proton_version {
self.proton_version = v;
+3 -13
View File
@@ -80,10 +80,7 @@ fn collect_prefixes(dir: &Path, depth: u32, out: &mut Vec<PathBuf>) {
}
}
fn match_launchers(
config: &Config,
prefixes: &[PathBuf],
) -> HashMap<String, Vec<PathBuf>> {
fn match_launchers(config: &Config, prefixes: &[PathBuf]) -> HashMap<String, Vec<PathBuf>> {
let mut by_launcher: HashMap<String, Vec<PathBuf>> = HashMap::new();
for l in &config.launchers {
for prefix in prefixes {
@@ -114,11 +111,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>)
Some(matches) => {
let detected = &matches[0];
if *detected == l.prefix_dir {
println!(
" \x1b[1;32m✓\x1b[0m {:12} {}",
l.name,
detected.display()
);
println!(" \x1b[1;32m✓\x1b[0m {:12} {}", l.name, detected.display());
} else {
any_divergent = true;
println!(
@@ -136,10 +129,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>)
}
}
fn apply_findings(
config: &Config,
by_launcher: &HashMap<String, Vec<PathBuf>>,
) -> Result<()> {
fn apply_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>) -> Result<()> {
let mut c = config.clone();
let mut updated = 0;
let mut ambiguous = 0;
+17 -14
View File
@@ -12,10 +12,18 @@ struct Check {
impl Check {
fn pass(label: impl Into<String>, detail: impl Into<String>) -> Self {
Self { label: label.into(), pass: true, detail: detail.into() }
Self {
label: label.into(),
pass: true,
detail: detail.into(),
}
}
fn fail(label: impl Into<String>, detail: impl Into<String>) -> Self {
Self { label: label.into(), pass: false, detail: detail.into() }
Self {
label: label.into(),
pass: false,
detail: detail.into(),
}
}
}
@@ -81,7 +89,10 @@ fn global_vulkan_check() -> Check {
if ok {
Check::pass("vulkan", "vulkaninfo OK")
} else {
Check::fail("vulkan", "vulkaninfo failed — check GPU drivers / vulkan-tools")
Check::fail(
"vulkan",
"vulkaninfo failed — check GPU drivers / vulkan-tools",
)
}
}
@@ -130,10 +141,7 @@ fn wineserver_check(config: &Config) -> Check {
if count == 0 {
return Check::pass("wine procs", "no wineserver running");
}
let any_running = config
.launchers
.iter()
.any(crate::launcher::is_running);
let any_running = config.launchers.iter().any(crate::launcher::is_running);
if any_running {
Check::pass(
"wine procs",
@@ -142,9 +150,7 @@ fn wineserver_check(config: &Config) -> Check {
} else {
Check::fail(
"wine procs",
format!(
"{count} stale wineserver process(es) — try: umutray kill"
),
format!("{count} stale wineserver process(es) — try: umutray kill"),
)
}
}
@@ -190,10 +196,7 @@ fn launcher_checks(l: &Launcher) -> Vec<Check> {
}
if is_owned_by_current_user(&l.prefix_dir) {
out.push(Check::pass(
format!("{tag} owner"),
"owned by current user",
));
out.push(Check::pass(format!("{tag} owner"), "owned by current user"));
} else {
out.push(Check::fail(
format!("{tag} owner"),
+24 -27
View File
@@ -188,10 +188,7 @@ enum ConfigAction {
gamescope: Option<String>,
},
/// Remove a game from a launcher
RemoveGame {
launcher: String,
name: String,
},
RemoveGame { launcher: String, name: String },
/// Toggle per-game overlay flags
SetGameFlags {
launcher: String,
@@ -267,7 +264,10 @@ fn main() -> Result<()> {
}
}
Commands::Play { launcher: lname, game: gname } => {
Commands::Play {
launcher: lname,
game: gname,
} => {
let l = config.find(&lname).ok_or_else(|| {
anyhow::anyhow!("unknown launcher '{lname}' — try `umutray launchers`")
})?;
@@ -294,7 +294,11 @@ fn main() -> Result<()> {
println!(" {}:", l.display);
for g in &l.games {
let installed = g.full_exe_path(l).exists();
let marker = if installed { "\x1b[1;32m✓\x1b[0m" } else { "·" };
let marker = if installed {
"\x1b[1;32m✓\x1b[0m"
} else {
"·"
};
let flags = format_game_flags(g);
println!(" {marker} {:14} {}{}", g.name, g.display, flags);
}
@@ -312,7 +316,11 @@ fn main() -> Result<()> {
detect::run(&config, &dir, apply)?;
}
Commands::UpdateProton { latest, version, list } => {
Commands::UpdateProton {
latest,
version,
list,
} => {
proton::run(&config, latest, version, list)?;
}
@@ -322,7 +330,10 @@ fn main() -> Result<()> {
println!("{}", config::Config::config_path()?.display());
}
ConfigAction::Edit => config::Config::edit()?,
ConfigAction::Set { proton_version, compat_dir } => {
ConfigAction::Set {
proton_version,
compat_dir,
} => {
let mut c = config;
c.set_globals(proton_version, compat_dir)?;
}
@@ -360,18 +371,9 @@ fn main() -> Result<()> {
gamescope,
} => {
let mut c = config;
let gs = gamescope.map(|s| {
s.split_whitespace().map(String::from).collect::<Vec<_>>()
});
c.add_game(
&launcher,
name,
display,
exe_path,
gamemode,
mangohud,
gs,
)?;
let gs =
gamescope.map(|s| s.split_whitespace().map(String::from).collect::<Vec<_>>());
c.add_game(&launcher, name, display, exe_path, gamemode, mangohud, gs)?;
}
ConfigAction::RemoveGame { launcher, name } => {
let mut c = config;
@@ -388,13 +390,8 @@ fn main() -> Result<()> {
let gs_update = if no_gamescope {
Some(None)
} else {
gamescope.map(|s| {
Some(
s.split_whitespace()
.map(String::from)
.collect::<Vec<_>>(),
)
})
gamescope
.map(|s| Some(s.split_whitespace().map(String::from).collect::<Vec<_>>()))
};
let mut c = config;
c.set_game_flags(&launcher, &name, gamemode, mangohud, gs_update)?;
+18 -11
View File
@@ -3,8 +3,7 @@ use anyhow::{Context, Result};
use serde::Deserialize;
use std::io::Write;
const GITHUB_API: &str =
"https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases";
const GITHUB_API: &str = "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases";
#[derive(Deserialize)]
struct Release {
@@ -153,7 +152,11 @@ fn print_list(config: &Config) -> Result<()> {
let releases = fetch_releases(10)?;
for r in &releases {
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
let marker = if installed { " \x1b[1;32m✓ installed\x1b[0m" } else { "" };
let marker = if installed {
" \x1b[1;32m✓ installed\x1b[0m"
} else {
""
};
println!(" {}{}", r.tag_name, marker);
}
Ok(())
@@ -170,7 +173,12 @@ struct ProgressWriter<W: Write> {
impl<W: Write> ProgressWriter<W> {
fn new(inner: W, total: Option<u64>) -> Self {
Self { inner, total, written: 0, last_print: 0 }
Self {
inner,
total,
written: 0,
last_print: 0,
}
}
fn finish(&mut self) {
@@ -189,12 +197,7 @@ impl<W: Write> Write for ProgressWriter<W> {
match self.total {
Some(t) => {
let pct = (self.written as f64 / t as f64) * 100.0;
eprint!(
"\r {:.1}% ({} / {} MiB)",
pct,
self.written >> 20,
t >> 20,
);
eprint!("\r {:.1}% ({} / {} MiB)", pct, self.written >> 20, t >> 20,);
}
None => eprint!("\r {} MiB", self.written >> 20),
}
@@ -217,7 +220,11 @@ fn pick_interactively(config: &Config) -> Result<String> {
println!("Recent GE-Proton releases:");
for (i, r) in releases.iter().enumerate() {
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
let marker = if installed { " \x1b[1;32m✓\x1b[0m" } else { "" };
let marker = if installed {
" \x1b[1;32m✓\x1b[0m"
} else {
""
};
println!(" {:2}) {}{}", i + 1, r.tag_name, marker);
}
+3 -6
View File
@@ -43,13 +43,11 @@ fn systemctl(args: &[&str]) -> Result<()> {
/// Write the unit, reload systemd, and enable+start the service.
pub fn install() -> Result<()> {
let exe = std::env::current_exe()
.context("Cannot determine path to own executable")?;
let exe = std::env::current_exe().context("Cannot determine path to own executable")?;
let path = unit_path()?;
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)
.with_context(|| format!("Failed to create {parent:?}"))?;
std::fs::create_dir_all(parent).with_context(|| format!("Failed to create {parent:?}"))?;
}
let contents = render_unit(&exe);
@@ -77,8 +75,7 @@ pub fn uninstall() -> Result<()> {
let _ = systemctl(&["disable", "--now", UNIT_NAME]);
if path.exists() {
std::fs::remove_file(&path)
.with_context(|| format!("Failed to remove {path:?}"))?;
std::fs::remove_file(&path).with_context(|| format!("Failed to remove {path:?}"))?;
println!("Removed {}", path.display());
} else {
println!("No unit file at {}", path.display());
+3 -9
View File
@@ -119,8 +119,7 @@ fn update(state: &mut State, message: Message) -> Task<Message> {
return Task::none();
};
state.stage = Stage::Installing;
state.status =
"Running installer via umu-run (this may take several minutes)…".into();
state.status = "Running installer via umu-run (this may take several minutes)…".into();
if let Ok(mut v) = state.log.lock() {
v.clear();
}
@@ -165,11 +164,7 @@ fn subscription(state: &State) -> Subscription<Message> {
fn view(state: &State) -> Element<'_, Message> {
let header = text(format!("Setup: {}", state.launcher.display)).size(24);
let prefix = text(format!(
"Prefix: {}",
state.launcher.prefix_dir.display()
))
.size(13);
let prefix = text(format!("Prefix: {}", state.launcher.prefix_dir.display())).size(13);
let expected = text(format!(
"Expected: {}",
state.launcher.full_exe_path().display()
@@ -180,8 +175,7 @@ fn view(state: &State) -> Element<'_, Message> {
.on_input(Message::SourceChanged)
.padding(8);
let prepare_enabled =
matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished);
let prepare_enabled = matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished);
let install_enabled = matches!(state.stage, Stage::Ready);
let prepare_btn = button(text("Download / Prepare"))