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:
+15
-39
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user