From 8258526ef368c87413ea25e8b0a7f9fbf6339ee1 Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 11:19:38 +0000 Subject: [PATCH 1/8] refactor stderr hiding to an enum --- src/backends/apt.rs | 4 ++-- src/backends/arch.rs | 10 +++++----- src/backends/brew.rs | 6 +++--- src/backends/bun.rs | 4 ++-- src/backends/cargo.rs | 4 ++-- src/backends/dnf.rs | 6 +++--- src/backends/flatpak.rs | 44 +++++++++++++++++++++++++++++++++++------ src/backends/mas.rs | 4 ++-- src/backends/mise.rs | 6 +++--- src/backends/npm.rs | 4 ++-- src/backends/pipx.rs | 4 ++-- src/backends/pnpm.rs | 4 ++-- src/backends/scoop.rs | 4 ++-- src/backends/snap.rs | 4 ++-- src/backends/uv.rs | 4 ++-- src/backends/vscode.rs | 4 ++-- src/backends/winget.rs | 4 ++-- src/backends/xbps.rs | 4 ++-- src/backends/yarn.rs | 4 ++-- src/backends/zypper.rs | 4 ++-- src/cmd.rs | 10 ++++++++-- src/prelude.rs | 2 +- 22 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/backends/apt.rs b/src/backends/apt.rs index 5658bf23..1d343962 100644 --- a/src/backends/apt.rs +++ b/src/backends/apt.rs @@ -62,7 +62,7 @@ impl Backend for Apt { // designed with this use-case in mind so there are lots and // lots of different methods all of which seem to have // caveats. - let explicit = run_command_for_stdout(["apt-mark", "showmanual"], Perms::Same, false)?; + let explicit = run_command_for_stdout(["apt-mark", "showmanual"], Perms::Same, StdErr::Show)?; Ok(explicit .lines() .map(|x| (x.to_string(), Self::PackageOptions {})) @@ -151,6 +151,6 @@ impl Backend for Apt { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["apt", "--version"], Perms::Same, false) + run_command_for_stdout(["apt", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/arch.rs b/src/backends/arch.rs index 2c81a72c..e2d791ba 100644 --- a/src/backends/arch.rs +++ b/src/backends/arch.rs @@ -98,13 +98,13 @@ impl Backend for Arch { "--quiet", ], Perms::Same, - false, + StdErr::Show, )?; let installed = run_command_for_stdout( [config.package_manager.as_command(), "--query", "--quiet"], Perms::Same, - false, + StdErr::Show, )?; Ok(all @@ -129,7 +129,7 @@ impl Backend for Arch { "--quiet", ], Perms::Same, - false, + StdErr::Show, )?; let mut result = BTreeMap::new(); @@ -189,7 +189,7 @@ impl Backend for Arch { "--quiet", ], Perms::Same, - false, + StdErr::Show, )?; let orphans = orphans_output.lines(); @@ -274,7 +274,7 @@ impl Backend for Arch { run_command_for_stdout( [config.package_manager.as_command(), "--version"], Perms::Same, - false, + StdErr::Show, ) } } diff --git a/src/backends/brew.rs b/src/backends/brew.rs index 8f973c40..fe91377d 100644 --- a/src/backends/brew.rs +++ b/src/backends/brew.rs @@ -60,13 +60,13 @@ impl Backend for Brew { let formulae = run_command_for_stdout( ["brew", "list", "-1", "--quiet", "--installed-on-request"], Perms::Same, - false, + StdErr::Show, )?; let casks = run_command_for_stdout( ["brew", "list", "-1", "--cask", "--quiet"], Perms::Same, - false, + StdErr::Show, )?; Ok(formulae @@ -150,6 +150,6 @@ impl Backend for Brew { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["brew", "--version"], Perms::Same, false) + run_command_for_stdout(["brew", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/bun.rs b/src/backends/bun.rs index 6135ce37..c7c43633 100644 --- a/src/backends/bun.rs +++ b/src/backends/bun.rs @@ -46,7 +46,7 @@ impl Backend for Bun { } let output = - match run_command_for_stdout(["bun", "pm", "ls", "--global"], Perms::Same, true) { + match run_command_for_stdout(["bun", "pm", "ls", "--global"], Perms::Same, StdErr::Hide) { Ok(output) => output, //unfortunately when there are no global packages installed bun returns an error rather //than saying zero packages @@ -156,6 +156,6 @@ impl Backend for Bun { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["bun", "--version"], Perms::Same, false) + run_command_for_stdout(["bun", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/cargo.rs b/src/backends/cargo.rs index 3ad738b6..d03b778b 100644 --- a/src/backends/cargo.rs +++ b/src/backends/cargo.rs @@ -181,7 +181,7 @@ impl Backend for Cargo { } fn clean_cache(_: &Self::Config) -> Result<()> { - run_command_for_stdout(["cargo-cache", "-V"], Perms::Same, false).map_or(Ok(()), |_| { + run_command_for_stdout(["cargo-cache", "-V"], Perms::Same, StdErr::Show).map_or(Ok(()), |_| { run_command(["cargo", "cache", "-a"], Perms::Same) }) } @@ -199,7 +199,7 @@ impl Backend for Cargo { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["cargo", "--version"], Perms::Same, false) + run_command_for_stdout(["cargo", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/dnf.rs b/src/backends/dnf.rs index 1ee216e6..c96133d8 100644 --- a/src/backends/dnf.rs +++ b/src/backends/dnf.rs @@ -55,7 +55,7 @@ impl Backend for Dnf { "%{name}\n", ], Perms::Same, - false, + StdErr::Show, )?; Ok(packages @@ -140,7 +140,7 @@ impl Backend for Dnf { } fn get_installed_repos(_: &Self::Config) -> Result> { - let repos = run_command_for_stdout(["dnf", "copr", "list"], Perms::Sudo, false)?; + let repos = run_command_for_stdout(["dnf", "copr", "list"], Perms::Sudo, StdErr::Show)?; let repos = repos .lines() @@ -181,6 +181,6 @@ impl Backend for Dnf { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["dnf", "--version"], Perms::Same, false) + run_command_for_stdout(["dnf", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 904b3a4a..94b6b6ea 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -26,7 +26,10 @@ pub struct FlatpakPackageOptions { #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(deny_unknown_fields)] -pub struct FlatpakRepoOptions {} +pub struct FlatpakRepoOptions { + pub installation: Option, + pub url: Option, +} impl Backend for Flatpak { type Config = FlatpakConfig; @@ -60,7 +63,7 @@ impl Backend for Flatpak { "--columns=application,installation", ], Perms::Same, - false, + StdErr::Show, )?; let apps = apps.lines().map(|line| { @@ -162,11 +165,40 @@ impl Backend for Flatpak { } fn get_installed_repos(_: &Self::Config) -> Result> { - Ok(BTreeMap::new()) + let repos = run_command_for_stdout( + ["flatpak", "remotes", "--columns", "name,options,url"], + Perms::Sudo, + StdErr::Show, + )?; + + let repos = repos + .lines() + .map(|line| { + let parts = line.split_whitespace().collect::>(); + ( + parts[0].to_string(), + FlatpakRepoOptions { + installation: Some(parts[1].to_string()), + url: Some(parts[2].to_string()), + }, + ) + }) + .collect(); + + Ok(repos) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, no_confirm: bool, config: &Self::Config) -> Result<()> { + for repo in repos.keys() { + run_command( + ["dnf", "copr", "enable", repo.as_str()] + .into_iter() + .chain(Some("--assumeyes").filter(|_| no_confirm)), + Perms::Sudo, + )? + } + + Ok(()) } fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { @@ -174,6 +206,6 @@ impl Backend for Flatpak { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["flatpak", "--version"], Perms::Same, false) + run_command_for_stdout(["flatpak", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/mas.rs b/src/backends/mas.rs index 56f80f5e..44c4511a 100644 --- a/src/backends/mas.rs +++ b/src/backends/mas.rs @@ -45,7 +45,7 @@ impl Backend for Mas { return Ok(BTreeMap::new()); } - let output = run_command_for_stdout(["mas", "list"], Perms::Same, false)?; + let output = run_command_for_stdout(["mas", "list"], Perms::Same, StdErr::Show)?; Ok(output .lines() @@ -119,6 +119,6 @@ impl Backend for Mas { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["mas", "version"], Perms::Same, false) + run_command_for_stdout(["mas", "version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/mise.rs b/src/backends/mise.rs index c823006b..8e186075 100644 --- a/src/backends/mise.rs +++ b/src/backends/mise.rs @@ -43,7 +43,7 @@ impl Backend for Mise { let search = run_command_for_stdout( ["mise", "search", "--no-headers", "--quiet"], Perms::Same, - true, + StdErr::Hide, )?; Ok(search @@ -75,7 +75,7 @@ impl Backend for Mise { "--quiet", ], Perms::Same, - true, + StdErr::Hide, )?; let packages_json = match serde_json::from_str(&packages)? { @@ -163,6 +163,6 @@ impl Backend for Mise { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["mise", "--version"], Perms::Same, false) + run_command_for_stdout(["mise", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/npm.rs b/src/backends/npm.rs index b00b4cbb..d4d7a679 100644 --- a/src/backends/npm.rs +++ b/src/backends/npm.rs @@ -47,7 +47,7 @@ impl Backend for Npm { } let stdout = - run_command_for_stdout(["npm", "list", "--global", "--json"], Perms::Same, false)?; + run_command_for_stdout(["npm", "list", "--global", "--json"], Perms::Same, StdErr::Show)?; let value: Value = serde_json::from_str(&stdout)?; let object = value.as_object().ok_or(eyre!("json should be an object"))?; @@ -134,6 +134,6 @@ impl Backend for Npm { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["npm", "--version"], Perms::Same, false) + run_command_for_stdout(["npm", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/pipx.rs b/src/backends/pipx.rs index a52603b1..f499a4c8 100644 --- a/src/backends/pipx.rs +++ b/src/backends/pipx.rs @@ -53,7 +53,7 @@ impl Backend for Pipx { let names = extract_package_names(run_command_for_stdout( ["pipx", "list", "--json"], Perms::Same, - true, + StdErr::Hide, )?)?; Ok(names @@ -121,7 +121,7 @@ impl Backend for Pipx { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["pipx", "--version"], Perms::Same, false) + run_command_for_stdout(["pipx", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/pnpm.rs b/src/backends/pnpm.rs index e576f2d9..8a50449e 100644 --- a/src/backends/pnpm.rs +++ b/src/backends/pnpm.rs @@ -48,7 +48,7 @@ impl Backend for Pnpm { } let stdout = - run_command_for_stdout(["pnpm", "list", "--global", "--json"], Perms::Same, false)?; + run_command_for_stdout(["pnpm", "list", "--global", "--json"], Perms::Same, StdErr::Show)?; let value: Value = serde_json::from_str(&stdout)?; let first_object = value.as_array().ok_or(eyre!("json should be an array"))?[0] @@ -137,6 +137,6 @@ impl Backend for Pnpm { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["pnpm", "--version"], Perms::Same, false) + run_command_for_stdout(["pnpm", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/scoop.rs b/src/backends/scoop.rs index 1ba542dd..aa37cd84 100644 --- a/src/backends/scoop.rs +++ b/src/backends/scoop.rs @@ -56,7 +56,7 @@ impl Backend for Scoop { return Ok(BTreeMap::new()); } - let output = run_command_for_stdout(["scoop.cmd", "list"], Perms::Same, false)?; + let output = run_command_for_stdout(["scoop.cmd", "list"], Perms::Same, StdErr::Show)?; let lines = output.lines().collect::>(); let mut packages = BTreeMap::new(); @@ -138,7 +138,7 @@ impl Backend for Scoop { } fn version(_: &Self::Config) -> Result { - let output = run_command_for_stdout(["scoop.cmd", "--version"], Perms::Same, false)?; + let output = run_command_for_stdout(["scoop.cmd", "--version"], Perms::Same, StdErr::Show)?; Ok(output.lines().nth(1).unwrap().to_string()) } diff --git a/src/backends/snap.rs b/src/backends/snap.rs index 9dc0bccd..4e56b67e 100644 --- a/src/backends/snap.rs +++ b/src/backends/snap.rs @@ -84,7 +84,7 @@ impl Backend for Snap { return Ok(BTreeMap::new()); } - let output = run_command_for_stdout(["snap", "list"], Perms::Same, false)?; + let output = run_command_for_stdout(["snap", "list"], Perms::Same, StdErr::Show)?; // Skip the first line which is the header Ok(output @@ -159,7 +159,7 @@ impl Backend for Snap { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["snap", "--version"], Perms::Same, false).map(|output| { + run_command_for_stdout(["snap", "--version"], Perms::Same, StdErr::Show).map(|output| { output .lines() .next() diff --git a/src/backends/uv.rs b/src/backends/uv.rs index 0d2f447e..f90bbd97 100644 --- a/src/backends/uv.rs +++ b/src/backends/uv.rs @@ -55,7 +55,7 @@ impl Backend for Uv { let names = run_command_for_stdout( ["uv", "tool", "list", "--color", "never"], Perms::Same, - true, + StdErr::Hide, )? .lines() .filter(|x| !x.starts_with("-")) @@ -136,6 +136,6 @@ impl Backend for Uv { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["uv", "--version"], Perms::Same, false) + run_command_for_stdout(["uv", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/vscode.rs b/src/backends/vscode.rs index 23c7e7d9..d100ad01 100644 --- a/src/backends/vscode.rs +++ b/src/backends/vscode.rs @@ -71,7 +71,7 @@ impl Backend for VsCode { let names = run_command_for_stdout( [config.variant.as_command(), "--list-extensions"], Perms::Same, - true, + StdErr::Hide, )? .lines() .map(|x| (x.to_string(), Self::PackageOptions {})) @@ -154,7 +154,7 @@ impl Backend for VsCode { run_command_for_stdout( [config.variant.as_command(), "--version"], Perms::Same, - false, + StdErr::Show, ) .map(|x| x.lines().join(" ")) } diff --git a/src/backends/winget.rs b/src/backends/winget.rs index ab038349..b6d5c65d 100644 --- a/src/backends/winget.rs +++ b/src/backends/winget.rs @@ -68,7 +68,7 @@ impl Backend for WinGet { tempfile.path().to_str().unwrap(), ], Perms::Same, - false, + StdErr::Show, )?; let mut export = String::new(); @@ -156,6 +156,6 @@ impl Backend for WinGet { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["winget", "--version"], Perms::Same, false) + run_command_for_stdout(["winget", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/xbps.rs b/src/backends/xbps.rs index b37beaf3..04e3f171 100644 --- a/src/backends/xbps.rs +++ b/src/backends/xbps.rs @@ -48,7 +48,7 @@ impl Backend for Xbps { } let stdout = - run_command_for_stdout(["xbps-query", "--list-manual-pkgs"], Perms::Same, false)?; + run_command_for_stdout(["xbps-query", "--list-manual-pkgs"], Perms::Same, StdErr::Show)?; // Removes the package version from output let re = Regex::new(r"-[^-]*$")?; @@ -158,6 +158,6 @@ impl Backend for Xbps { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["xbps-query", "--version"], Perms::Same, false) + run_command_for_stdout(["xbps-query", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/yarn.rs b/src/backends/yarn.rs index 9f642618..94c5849f 100644 --- a/src/backends/yarn.rs +++ b/src/backends/yarn.rs @@ -51,7 +51,7 @@ impl Backend for Yarn { //have binaries, see https://github.com/yarnpkg/yarn/issues/5725 // //instead we manually read the global `package.json` file - let dir = run_command_for_stdout(["yarn", "global", "dir"], Perms::Same, true)?; + let dir = run_command_for_stdout(["yarn", "global", "dir"], Perms::Same, StdErr::Hide)?; let dir = dir .lines() .next() @@ -151,6 +151,6 @@ impl Backend for Yarn { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["yarn", "--version"], Perms::Same, false) + run_command_for_stdout(["yarn", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/backends/zypper.rs b/src/backends/zypper.rs index 86f06e6f..2c1c033a 100644 --- a/src/backends/zypper.rs +++ b/src/backends/zypper.rs @@ -51,7 +51,7 @@ impl Backend for Zypper { let stdout = run_command_for_stdout( ["zypper", "packages", "--userinstalled"], Perms::Same, - false, + StdErr::Show, )?; stdout @@ -156,6 +156,6 @@ impl Backend for Zypper { } fn version(_: &Self::Config) -> Result { - run_command_for_stdout(["zypper", "--version"], Perms::Same, false) + run_command_for_stdout(["zypper", "--version"], Perms::Same, StdErr::Show) } } diff --git a/src/cmd.rs b/src/cmd.rs index 0a41c96c..2eac8c72 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -13,7 +13,13 @@ pub enum Perms { Same, } -pub fn run_command_for_stdout(args: I, perms: Perms, hide_stderr: bool) -> Result +#[derive(Debug, Clone, Copy)] +pub enum StdErr { + Show, + Hide, +} + +pub fn run_command_for_stdout(args: I, perms: Perms, stderr: StdErr) -> Result where S: Into, I: IntoIterator, @@ -39,7 +45,7 @@ where .args(remaining_args) .stdin(Stdio::inherit()) .stdout(Stdio::piped()) - .stderr(if !hide_stderr { + .stderr(if matches!(stderr, StdErr::Show) { Stdio::inherit() } else { Stdio::null() diff --git a/src/prelude.rs b/src/prelude.rs index baea549d..7d525029 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -28,7 +28,7 @@ pub use crate::cli::{ BackendsCommand, CleanCacheCommand, CleanCommand, MainArguments, MainSubcommand, SyncCommand, UnmanagedCommand, UpdateAllCommand, UpdateCommand, }; -pub use crate::cmd::Perms; +pub use crate::cmd::{Perms, StdErr}; pub use crate::config::Config; pub use crate::groups::Groups; pub use crate::hooks::Hooks; From a628398c18c6d3bbc200c861ab49a5d8644cd0fa Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 11:31:34 +0000 Subject: [PATCH 2/8] temp --- README.md | 12 ++++---- src/backends/flatpak.rs | 67 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8cec75c8..5a223f56 100644 --- a/README.md +++ b/README.md @@ -344,12 +344,12 @@ locked = false binstall = false [flatpak] -# The default installation to use for flatpak packages. If equal to "user" -# then the --user option is passed when installing packages, if it is equal -# to "system" then the "--system" option is passed, and if it is equal to -# anything else then "--installation={installation}" is passed. If this is -# not set then nothing is passed. This config can be overridden on a -# per-package basis. +# The default installation to use for flatpak packages and remotes. If equal +# to "user" then the --user option is passed when installing packages or +# remotes, if it is equal to "system" then the "--system" option is passed, +# and if it is equal to anything else then "--installation={installation}" +# is passed. If this is not set then nothing is passed. This config can be +# overridden on a per-package basis. # Default: None installation = "system" diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 94b6b6ea..457b2471 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -188,12 +188,37 @@ impl Backend for Flatpak { Ok(repos) } - fn add_repos(repos: &BTreeMap, no_confirm: bool, config: &Self::Config) -> Result<()> { - for repo in repos.keys() { + fn add_repos( + repos: &BTreeMap, + no_confirm: bool, + config: &Self::Config, + ) -> Result<()> { + for (repo, options) in repos { run_command( - ["dnf", "copr", "enable", repo.as_str()] + ["dnf", "remote-add"] + .map(ToString::to_string) .into_iter() - .chain(Some("--assumeyes").filter(|_| no_confirm)), + .chain(Some("--assumeyes".to_string()).filter(|_| no_confirm)) + .chain( + match options + .installation + .as_deref() + .or(config.installation.as_deref()) + { + Some("user") => Some("--user".to_string()), + Some("system") => Some("--system".to_string()), + Some(x) => Some(format!("--installation={x}")), + None => None, + }, + ) + .chain([ + repo.to_string(), + options + .url + .as_deref() + .ok_or(eyre!("flatpak repos must have the url option set"))? + .to_string(), + ]), Perms::Sudo, )? } @@ -201,8 +226,38 @@ impl Backend for Flatpak { Ok(()) } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, no_confirm: bool, config: &Self::Config) -> Result<()> { + for (repo, options) in repos { + run_command( + ["dnf", "remote-delete", repo.as_str()] + .map(ToString::to_string) + .into_iter() + .chain(Some("--assumeyes".to_string()).filter(|_| no_confirm)) + .chain( + match options + .installation + .as_deref() + .or(config.installation.as_deref()) + { + Some("user") => Some("--user".to_string()), + Some("system") => Some("--system".to_string()), + Some(x) => Some(format!("--installation={x}")), + None => None, + }, + ) + .chain([ + repo.to_string(), + options + .url + .as_deref() + .ok_or(eyre!("flatpak repos must have the url option set"))? + .to_string(), + ]), + Perms::Sudo, + )? + } + + Ok(()) } fn version(_: &Self::Config) -> Result { From af52242ed55fb5467ca14652c5b9af0a7dc2844e Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 12:13:46 +0000 Subject: [PATCH 3/8] temp --- README.md | 11 --- src/backends/apt.rs | 23 ++++-- src/backends/arch.rs | 16 +++- src/backends/brew.rs | 16 +++- src/backends/bun.rs | 16 +++- src/backends/cargo.rs | 16 +++- src/backends/flatpak.rs | 175 +++++++++++++++++++++++----------------- src/backends/mas.rs | 16 +++- src/backends/mise.rs | 16 +++- src/backends/npm.rs | 16 +++- src/backends/pipx.rs | 16 +++- src/backends/pnpm.rs | 16 +++- src/backends/scoop.rs | 16 +++- src/backends/snap.rs | 16 +++- src/backends/uv.rs | 16 +++- src/backends/vscode.rs | 16 +++- src/backends/winget.rs | 16 +++- src/backends/xbps.rs | 16 +++- src/backends/yarn.rs | 16 +++- src/backends/zypper.rs | 16 +++- src/core.rs | 4 +- 21 files changed, 324 insertions(+), 161 deletions(-) diff --git a/README.md b/README.md index 5a223f56..c05ecefd 100644 --- a/README.md +++ b/README.md @@ -343,16 +343,6 @@ locked = false # Default: false binstall = false -[flatpak] -# The default installation to use for flatpak packages and remotes. If equal -# to "user" then the --user option is passed when installing packages or -# remotes, if it is equal to "system" then the "--system" option is passed, -# and if it is equal to anything else then "--installation={installation}" -# is passed. If this is not set then nothing is passed. This config can be -# overridden on a per-package basis. -# Default: None -installation = "system" - [vscode] # Since VSCode and VSCodium both operate on the same package database # they are mutually exclusive and so you must pick which one you want @@ -369,7 +359,6 @@ variant = "code" # If this is `true` then the system is updated with the subcommand `dist-upgrade` (`dup`). # Default: false distribution_upgrade = false - ``` ## Group Files diff --git a/src/backends/apt.rs b/src/backends/apt.rs index 1d343962..c42b7b91 100644 --- a/src/backends/apt.rs +++ b/src/backends/apt.rs @@ -62,7 +62,8 @@ impl Backend for Apt { // designed with this use-case in mind so there are lots and // lots of different methods all of which seem to have // caveats. - let explicit = run_command_for_stdout(["apt-mark", "showmanual"], Perms::Same, StdErr::Show)?; + let explicit = + run_command_for_stdout(["apt-mark", "showmanual"], Perms::Same, StdErr::Show)?; Ok(explicit .lines() .map(|x| (x.to_string(), Self::PackageOptions {})) @@ -142,12 +143,24 @@ impl Backend for Apt { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/arch.rs b/src/backends/arch.rs index e2d791ba..ab651d90 100644 --- a/src/backends/arch.rs +++ b/src/backends/arch.rs @@ -262,12 +262,20 @@ impl Backend for Arch { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(config: &Self::Config) -> Result { diff --git a/src/backends/brew.rs b/src/backends/brew.rs index fe91377d..3848f93f 100644 --- a/src/backends/brew.rs +++ b/src/backends/brew.rs @@ -141,12 +141,20 @@ impl Backend for Brew { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/bun.rs b/src/backends/bun.rs index c7c43633..d2e00994 100644 --- a/src/backends/bun.rs +++ b/src/backends/bun.rs @@ -147,12 +147,20 @@ impl Backend for Bun { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/cargo.rs b/src/backends/cargo.rs index d03b778b..54af6dcf 100644 --- a/src/backends/cargo.rs +++ b/src/backends/cargo.rs @@ -190,12 +190,20 @@ impl Backend for Cargo { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 457b2471..8b17f034 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -13,21 +13,17 @@ pub struct Flatpak; #[serde_inline_default] #[derive(Debug, Serialize, Deserialize, Default)] #[serde(deny_unknown_fields)] -pub struct FlatpakConfig { - installation: Option, -} +pub struct FlatpakConfig {} #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct FlatpakPackageOptions { - pub installation: Option, pub remote: Option, } #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct FlatpakRepoOptions { - pub installation: Option, pub url: Option, } @@ -60,7 +56,7 @@ impl Backend for Flatpak { "flatpak", "list", "--app", - "--columns=application,installation", + "--columns=installation,application,origin", ], Perms::Same, StdErr::Show, @@ -70,10 +66,9 @@ impl Backend for Flatpak { let parts = line.split_whitespace().collect::>(); ( - parts[0].to_string(), + format!("{}:{}", parts[0], parts[1]), Self::PackageOptions { - installation: Some(parts[1].to_string()), - remote: None, + remote: Some(parts[2].to_string()), }, ) }); @@ -84,16 +79,19 @@ impl Backend for Flatpak { fn install_packages( packages: &BTreeMap, no_confirm: bool, - config: &Self::Config, + _: &Self::Config, ) -> Result<()> { - let mut groups = BTreeMap::new(); + //group packages for faster installation and less y/n prompts + let mut groups: BTreeMap<(String, Option), Vec> = BTreeMap::new(); for (package, options) in packages { - let installation = options.installation.clone().or(config.installation.clone()); - let remote = options.remote.clone(); + let (installation, package) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name, should be in form \"installation:package\"" + ))?; + groups - .entry((installation, remote)) - .or_insert_with(Vec::new) - .push(package.clone()); + .entry((installation.to_string(), options.remote.clone())) + .or_default() + .push(package.to_string()); } for ((installation, remote), packages) in groups { @@ -102,11 +100,10 @@ impl Backend for Flatpak { .into_iter() .chain(Some("--assumeyes").filter(|_| no_confirm)) .map(|x| x.to_string()) - .chain(match installation.as_deref() { - Some("user") => Some("--user".to_string()), - Some("system") => Some("--system".to_string()), - Some(x) => Some(format!("--installation={x}")), - None => None, + .chain(match installation.as_str() { + "user" => Some("--user".to_string()), + "system" => Some("--system".to_string()), + x => Some(format!("--installation={x}")), }) .chain(remote) .chain(packages), @@ -122,12 +119,31 @@ impl Backend for Flatpak { no_confirm: bool, _: &Self::Config, ) -> Result<()> { - if !packages.is_empty() { + //group packages for faster uninstallation and less y/n prompts + let mut groups: BTreeMap> = BTreeMap::new(); + for package in packages { + let (installation, package) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name, should be in form \"installation:package\", such as \"system:metapac\"" + ))?; + + groups + .entry(installation.to_string()) + .or_default() + .push(package.to_string()); + } + + for (installation, packages) in groups { run_command( ["flatpak", "uninstall"] .into_iter() .chain(Some("--assumeyes").filter(|_| no_confirm)) - .chain(packages.iter().map(String::as_str)), + .map(|x| x.to_string()) + .chain(match installation.as_str() { + "user" => Some("--user".to_string()), + "system" => Some("--system".to_string()), + x => Some(format!("--installation={x}")), + }) + .chain(packages), Perms::Same, )?; } @@ -140,13 +156,36 @@ impl Backend for Flatpak { no_confirm: bool, _: &Self::Config, ) -> Result<()> { - run_command( - ["flatpak", "update"] - .into_iter() - .chain(Some("--assumeyes").filter(|_| no_confirm)) - .chain(packages.iter().map(String::as_str)), - Perms::Same, - ) + //group packages for faster uninstallation and less y/n prompts + let mut groups: BTreeMap> = BTreeMap::new(); + for package in packages { + let (installation, package) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name, should be in form \"installation:package\", such as \"system:metapac\"" + ))?; + + groups + .entry(installation.to_string()) + .or_default() + .push(package.to_string()); + } + + for (installation, packages) in groups { + run_command( + ["flatpak", "update"] + .into_iter() + .chain(Some("--assumeyes").filter(|_| no_confirm)) + .map(|x| x.to_string()) + .chain(match installation.as_str() { + "user" => Some("--user".to_string()), + "system" => Some("--system".to_string()), + x => Some(format!("--installation={x}")), + }) + .chain(packages), + Perms::Same, + )?; + } + + Ok(()) } fn update_all_packages(no_confirm: bool, _: &Self::Config) -> Result<()> { @@ -166,7 +205,7 @@ impl Backend for Flatpak { fn get_installed_repos(_: &Self::Config) -> Result> { let repos = run_command_for_stdout( - ["flatpak", "remotes", "--columns", "name,options,url"], + ["flatpak", "remotes", "--columns", "options,name,url"], Perms::Sudo, StdErr::Show, )?; @@ -176,9 +215,8 @@ impl Backend for Flatpak { .map(|line| { let parts = line.split_whitespace().collect::>(); ( - parts[0].to_string(), + format!("{}:{}", parts[0], parts[1]), FlatpakRepoOptions { - installation: Some(parts[1].to_string()), url: Some(parts[2].to_string()), }, ) @@ -191,32 +229,29 @@ impl Backend for Flatpak { fn add_repos( repos: &BTreeMap, no_confirm: bool, - config: &Self::Config, + _: &Self::Config, ) -> Result<()> { for (repo, options) in repos { + let (installation, repo) = repo.split_once(":").ok_or(eyre!( + "invalid flatpak repo name, should be in form \"installation:repo\", such as \"system:flathub\"" + ))?; + run_command( - ["dnf", "remote-add"] - .map(ToString::to_string) + ["flatpak", "remote-add"] .into_iter() - .chain(Some("--assumeyes".to_string()).filter(|_| no_confirm)) - .chain( - match options - .installation - .as_deref() - .or(config.installation.as_deref()) - { - Some("user") => Some("--user".to_string()), - Some("system") => Some("--system".to_string()), - Some(x) => Some(format!("--installation={x}")), - None => None, - }, - ) + .chain(Some("--assumeyes").filter(|_| no_confirm)) + .map(ToString::to_string) + .chain(match installation { + "user" => Some("--user".to_string()), + "system" => Some("--system".to_string()), + x => Some(format!("--installation={x}")), + }) .chain([ repo.to_string(), options .url .as_deref() - .ok_or(eyre!("flatpak repos must have the url option set"))? + .ok_or(eyre!("flatpak repos must have the \"url\" option set"))? .to_string(), ]), Perms::Sudo, @@ -226,33 +261,23 @@ impl Backend for Flatpak { Ok(()) } - fn remove_repos(repos: &BTreeSet, no_confirm: bool, config: &Self::Config) -> Result<()> { - for (repo, options) in repos { + fn remove_repos(repos: &BTreeSet, no_confirm: bool, _: &Self::Config) -> Result<()> { + for repo in repos { + let (installation, repo) = repo.split_once(":").ok_or(eyre!( + "invalid flatpak repo name, should be in form \"installation:repo\", such as \"system:flathub\"" + ))?; + run_command( - ["dnf", "remote-delete", repo.as_str()] - .map(ToString::to_string) + ["flatpak", "remote-delete"] .into_iter() - .chain(Some("--assumeyes".to_string()).filter(|_| no_confirm)) - .chain( - match options - .installation - .as_deref() - .or(config.installation.as_deref()) - { - Some("user") => Some("--user".to_string()), - Some("system") => Some("--system".to_string()), - Some(x) => Some(format!("--installation={x}")), - None => None, - }, - ) - .chain([ - repo.to_string(), - options - .url - .as_deref() - .ok_or(eyre!("flatpak repos must have the url option set"))? - .to_string(), - ]), + .chain(Some("--assumeyes").filter(|_| no_confirm)) + .map(ToString::to_string) + .chain(match installation { + "user" => Some("--user".to_string()), + "system" => Some("--system".to_string()), + x => Some(format!("--installation={x}")), + }) + .chain([repo.to_string()]), Perms::Sudo, )? } diff --git a/src/backends/mas.rs b/src/backends/mas.rs index 44c4511a..715f2978 100644 --- a/src/backends/mas.rs +++ b/src/backends/mas.rs @@ -110,12 +110,20 @@ impl Backend for Mas { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/mise.rs b/src/backends/mise.rs index 8e186075..34ab755d 100644 --- a/src/backends/mise.rs +++ b/src/backends/mise.rs @@ -154,12 +154,20 @@ impl Backend for Mise { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/npm.rs b/src/backends/npm.rs index d4d7a679..4702fcf7 100644 --- a/src/backends/npm.rs +++ b/src/backends/npm.rs @@ -125,12 +125,20 @@ impl Backend for Npm { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/pipx.rs b/src/backends/pipx.rs index f499a4c8..ac610f91 100644 --- a/src/backends/pipx.rs +++ b/src/backends/pipx.rs @@ -112,12 +112,20 @@ impl Backend for Pipx { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/pnpm.rs b/src/backends/pnpm.rs index 8a50449e..2708bbc0 100644 --- a/src/backends/pnpm.rs +++ b/src/backends/pnpm.rs @@ -128,12 +128,20 @@ impl Backend for Pnpm { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/scoop.rs b/src/backends/scoop.rs index aa37cd84..a057f60e 100644 --- a/src/backends/scoop.rs +++ b/src/backends/scoop.rs @@ -129,12 +129,20 @@ impl Backend for Scoop { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/snap.rs b/src/backends/snap.rs index 4e56b67e..83674717 100644 --- a/src/backends/snap.rs +++ b/src/backends/snap.rs @@ -150,12 +150,20 @@ impl Backend for Snap { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/uv.rs b/src/backends/uv.rs index f90bbd97..47fe5e0b 100644 --- a/src/backends/uv.rs +++ b/src/backends/uv.rs @@ -127,12 +127,20 @@ impl Backend for Uv { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/vscode.rs b/src/backends/vscode.rs index d100ad01..e7685225 100644 --- a/src/backends/vscode.rs +++ b/src/backends/vscode.rs @@ -142,12 +142,20 @@ impl Backend for VsCode { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(config: &Self::Config) -> Result { diff --git a/src/backends/winget.rs b/src/backends/winget.rs index b6d5c65d..f7548563 100644 --- a/src/backends/winget.rs +++ b/src/backends/winget.rs @@ -147,12 +147,20 @@ impl Backend for WinGet { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/xbps.rs b/src/backends/xbps.rs index 04e3f171..d6468e96 100644 --- a/src/backends/xbps.rs +++ b/src/backends/xbps.rs @@ -149,12 +149,20 @@ impl Backend for Xbps { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/yarn.rs b/src/backends/yarn.rs index 94c5849f..36d1ab16 100644 --- a/src/backends/yarn.rs +++ b/src/backends/yarn.rs @@ -142,12 +142,20 @@ impl Backend for Yarn { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/backends/zypper.rs b/src/backends/zypper.rs index 2c1c033a..e3c8afaa 100644 --- a/src/backends/zypper.rs +++ b/src/backends/zypper.rs @@ -147,12 +147,20 @@ impl Backend for Zypper { Ok(BTreeMap::new()) } - fn add_repos(_: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } - fn remove_repos(_: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { - Err(eyre!("unimplemented")) + fn remove_repos(repos: &BTreeSet, _: bool, _: &Self::Config) -> Result<()> { + if repos.is_empty() { + Ok(()) + } else { + Err(eyre!("unimplemented")) + } } fn version(_: &Self::Config) -> Result { diff --git a/src/core.rs b/src/core.rs index f8ccab46..a0db1500 100644 --- a/src/core.rs +++ b/src/core.rs @@ -91,7 +91,7 @@ impl CleanCommand { if self.no_confirm { log::info!("proceeding to uninstall packages without confirmation"); } else if !Confirm::new() - .with_prompt("these packages will be uninstalled, do you want to continue?") + .with_prompt("these repos/packages will be uninstalled, do you want to continue?") .default(true) .show_default(true) .interact() @@ -134,7 +134,7 @@ impl SyncCommand { log::info!("proceeding to install packages without confirmation"); } else if !missing.is_empty() && !Confirm::new() - .with_prompt("these packages will be installed, do you want to continue?") + .with_prompt("these repos/packages will be installed, do you want to continue?") .default(true) .show_default(true) .interact() From 076cc37dc762cfbb1f4971c0144c3f0d7021ad21 Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 12:19:02 +0000 Subject: [PATCH 4/8] remove deprecate cargo.authors field --- Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a390fec3..848dcc80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,6 @@ repository = "https://github.com/ripytide/metapac" readme = "README.md" keywords = ["package-manager", "linux", "declarative", "cli"] categories = ["command-line-utilities"] -authors = [ - "James Forster ", - "Md Isfarul Haque Date: Sun, 25 Jan 2026 12:19:49 +0000 Subject: [PATCH 5/8] cargo update --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- Cargo.toml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca8110e2..01f875dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -678,9 +678,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" [[package]] name = "object" @@ -766,18 +766,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -796,7 +796,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.17", "libredox", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -914,9 +914,9 @@ dependencies = [ [[package]] name = "serde-inline-default" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d48532bc0781ac622a5fea0f16502d3b4f1af0fcebe56d618120969f35d315" +checksum = "2bf03b7a5281cfd4013bc788d057b0f09fc634397d83bc8973c955bd4f32727a" dependencies = [ "proc-macro2", "quote", @@ -1095,11 +1095,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.17", + "thiserror-impl 2.0.18", ] [[package]] @@ -1115,9 +1115,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", @@ -1135,9 +1135,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5" dependencies = [ "deranged", "itoa", @@ -1150,15 +1150,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4" dependencies = [ "num-conv", "time-core", @@ -1420,6 +1420,6 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zmij" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2" +checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65" diff --git a/Cargo.toml b/Cargo.toml index 848dcc80..c7e84d78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ dirs = "6.0.0" home = "0.5.12" pretty_env_logger = "0.5.0" dialoguer = "0.12.0" -serde-inline-default = "1.0.0" +serde-inline-default = "1.0.1" hostname = "0.4.2" walkdir = "2.5.0" toml_edit = { version = "0.24.0", features = ["serde", "display"] } From ede24dfb672014a33bc41b01cefac3848ec41937 Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 12:30:19 +0000 Subject: [PATCH 6/8] temp --- README.md | 20 ++++++++++---------- src/backends/flatpak.rs | 30 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index c05ecefd..9fa50c07 100644 --- a/README.md +++ b/README.md @@ -479,20 +479,20 @@ dnf = { packages = ["package1", { name = "package2" }] } flatpak = { - packages = [ - "package1", - { - name = "package2", - options = { remote = "flathub", installation = "user" }, - }, + repos = [ { - name = "package3", - options = { remote = "flathub", installation = "system" }, + name = "system:flathub", + options = { url = "https://dl.flathub.org/repo/" } }, { - name = "package4", - options = { remote = "flathub", installation = "my_custom_installation" }, + name = "system:fedora", + options = { url = "oci+https://registry.fedoraproject.org" } }, + ], + packages = [ + "system:metapac", + { name = "system:org.gimp.GIMP", options = { remote = "flathub" } }, + { name = "system:org.kde.krita", options = { remote = "fedora" } }, ] } mas = { packages = ["package1", { name = "package2" }] } diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 8b17f034..26ca4f7c 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -84,14 +84,14 @@ impl Backend for Flatpak { //group packages for faster installation and less y/n prompts let mut groups: BTreeMap<(String, Option), Vec> = BTreeMap::new(); for (package, options) in packages { - let (installation, package) = package.split_once(":").ok_or(eyre!( - "invalid flatpak package name, should be in form \"installation:package\"" + let (installation, name) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name: {package:?}, should be in form \"installation:package\", such as \"system:metapac\"" ))?; groups .entry((installation.to_string(), options.remote.clone())) .or_default() - .push(package.to_string()); + .push(name.to_string()); } for ((installation, remote), packages) in groups { @@ -122,14 +122,14 @@ impl Backend for Flatpak { //group packages for faster uninstallation and less y/n prompts let mut groups: BTreeMap> = BTreeMap::new(); for package in packages { - let (installation, package) = package.split_once(":").ok_or(eyre!( - "invalid flatpak package name, should be in form \"installation:package\", such as \"system:metapac\"" + let (installation, name) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name: {package:?}, should be in form \"installation:package\", such as \"system:metapac\"" ))?; groups .entry(installation.to_string()) .or_default() - .push(package.to_string()); + .push(name.to_string()); } for (installation, packages) in groups { @@ -159,14 +159,14 @@ impl Backend for Flatpak { //group packages for faster uninstallation and less y/n prompts let mut groups: BTreeMap> = BTreeMap::new(); for package in packages { - let (installation, package) = package.split_once(":").ok_or(eyre!( - "invalid flatpak package name, should be in form \"installation:package\", such as \"system:metapac\"" + let (installation, name) = package.split_once(":").ok_or(eyre!( + "invalid flatpak package name: {package:?}, should be in form \"installation:package\", such as \"system:metapac\"" ))?; groups .entry(installation.to_string()) .or_default() - .push(package.to_string()); + .push(name.to_string()); } for (installation, packages) in groups { @@ -232,8 +232,8 @@ impl Backend for Flatpak { _: &Self::Config, ) -> Result<()> { for (repo, options) in repos { - let (installation, repo) = repo.split_once(":").ok_or(eyre!( - "invalid flatpak repo name, should be in form \"installation:repo\", such as \"system:flathub\"" + let (installation, name) = repo.split_once(":").ok_or(eyre!( + "invalid flatpak repo name: {repo:?}, should be in form \"installation:repo\", such as \"system:flathub\"" ))?; run_command( @@ -247,7 +247,7 @@ impl Backend for Flatpak { x => Some(format!("--installation={x}")), }) .chain([ - repo.to_string(), + name.to_string(), options .url .as_deref() @@ -263,8 +263,8 @@ impl Backend for Flatpak { fn remove_repos(repos: &BTreeSet, no_confirm: bool, _: &Self::Config) -> Result<()> { for repo in repos { - let (installation, repo) = repo.split_once(":").ok_or(eyre!( - "invalid flatpak repo name, should be in form \"installation:repo\", such as \"system:flathub\"" + let (installation, name) = repo.split_once(":").ok_or(eyre!( + "invalid flatpak repo name: {repo:?}, should be in form \"installation:repo\", such as \"system:flathub\"" ))?; run_command( @@ -277,7 +277,7 @@ impl Backend for Flatpak { "system" => Some("--system".to_string()), x => Some(format!("--installation={x}")), }) - .chain([repo.to_string()]), + .chain([name.to_string()]), Perms::Sudo, )? } From 4e2ce7e5b6679b34d9e93085922b6dc4eee3923d Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 12:40:58 +0000 Subject: [PATCH 7/8] more flatpak examples --- README.md | 17 +++++++++++++---- src/backends/flatpak.rs | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9fa50c07..821684c7 100644 --- a/README.md +++ b/README.md @@ -485,14 +485,23 @@ flatpak = { options = { url = "https://dl.flathub.org/repo/" } }, { - name = "system:fedora", - options = { url = "oci+https://registry.fedoraproject.org" } + name = "user:ykc", + options = { url = "https://flatpak.yellowkeycard.net/ykc.flatpakrepo" } + }, + { + name = "custom_installation:flathub_beta", + options = { + url = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo" + } }, ], packages = [ - "system:metapac", { name = "system:org.gimp.GIMP", options = { remote = "flathub" } }, - { name = "system:org.kde.krita", options = { remote = "fedora" } }, + { name = "user:io.github.sonicgalactic", options = { remote = "ykc" } }, + { + name = "custom_installation:org.mozilla.firefox", + options = { remote = "flathub_beta" } + }, ] } mas = { packages = ["package1", { name = "package2" }] } diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 26ca4f7c..2cab39e4 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -214,8 +214,9 @@ impl Backend for Flatpak { .lines() .map(|line| { let parts = line.split_whitespace().collect::>(); + let installation = parts[0].split(",").collect::>()[0]; ( - format!("{}:{}", parts[0], parts[1]), + format!("{}:{}", installation, parts[1]), FlatpakRepoOptions { url: Some(parts[2].to_string()), }, From 9c81a8f1226cc03f56d5c0a4515689445dc13337 Mon Sep 17 00:00:00 2001 From: ripytide Date: Sun, 25 Jan 2026 12:46:12 +0000 Subject: [PATCH 8/8] cargo fmt --- src/backends/arch.rs | 6 +++++- src/backends/brew.rs | 6 +++++- src/backends/bun.rs | 23 +++++++++++++++-------- src/backends/cargo.rs | 13 +++++++++---- src/backends/mas.rs | 6 +++++- src/backends/mise.rs | 6 +++++- src/backends/npm.rs | 13 ++++++++++--- src/backends/pipx.rs | 6 +++++- src/backends/pnpm.rs | 13 ++++++++++--- src/backends/scoop.rs | 6 +++++- src/backends/snap.rs | 6 +++++- src/backends/uv.rs | 6 +++++- src/backends/vscode.rs | 6 +++++- src/backends/winget.rs | 6 +++++- src/backends/xbps.rs | 13 ++++++++++--- src/backends/yarn.rs | 6 +++++- src/backends/zypper.rs | 6 +++++- 17 files changed, 114 insertions(+), 33 deletions(-) diff --git a/src/backends/arch.rs b/src/backends/arch.rs index ab651d90..c82a929a 100644 --- a/src/backends/arch.rs +++ b/src/backends/arch.rs @@ -262,7 +262,11 @@ impl Backend for Arch { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/brew.rs b/src/backends/brew.rs index 3848f93f..352f93b8 100644 --- a/src/backends/brew.rs +++ b/src/backends/brew.rs @@ -141,7 +141,11 @@ impl Backend for Brew { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/bun.rs b/src/backends/bun.rs index d2e00994..efbfa9b1 100644 --- a/src/backends/bun.rs +++ b/src/backends/bun.rs @@ -45,13 +45,16 @@ impl Backend for Bun { return Ok(BTreeMap::new()); } - let output = - match run_command_for_stdout(["bun", "pm", "ls", "--global"], Perms::Same, StdErr::Hide) { - Ok(output) => output, - //unfortunately when there are no global packages installed bun returns an error rather - //than saying zero packages - Err(_) => return Ok(BTreeMap::new()), - }; + let output = match run_command_for_stdout( + ["bun", "pm", "ls", "--global"], + Perms::Same, + StdErr::Hide, + ) { + Ok(output) => output, + //unfortunately when there are no global packages installed bun returns an error rather + //than saying zero packages + Err(_) => return Ok(BTreeMap::new()), + }; let lines = output.lines().collect::>(); @@ -147,7 +150,11 @@ impl Backend for Bun { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/cargo.rs b/src/backends/cargo.rs index 54af6dcf..72ef9e3d 100644 --- a/src/backends/cargo.rs +++ b/src/backends/cargo.rs @@ -181,16 +181,21 @@ impl Backend for Cargo { } fn clean_cache(_: &Self::Config) -> Result<()> { - run_command_for_stdout(["cargo-cache", "-V"], Perms::Same, StdErr::Show).map_or(Ok(()), |_| { - run_command(["cargo", "cache", "-a"], Perms::Same) - }) + run_command_for_stdout(["cargo-cache", "-V"], Perms::Same, StdErr::Show) + .map_or(Ok(()), |_| { + run_command(["cargo", "cache", "-a"], Perms::Same) + }) } fn get_installed_repos(_: &Self::Config) -> Result> { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/mas.rs b/src/backends/mas.rs index 715f2978..fbd67a50 100644 --- a/src/backends/mas.rs +++ b/src/backends/mas.rs @@ -110,7 +110,11 @@ impl Backend for Mas { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/mise.rs b/src/backends/mise.rs index 34ab755d..f7a09dc0 100644 --- a/src/backends/mise.rs +++ b/src/backends/mise.rs @@ -154,7 +154,11 @@ impl Backend for Mise { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/npm.rs b/src/backends/npm.rs index 4702fcf7..d4b3d976 100644 --- a/src/backends/npm.rs +++ b/src/backends/npm.rs @@ -46,8 +46,11 @@ impl Backend for Npm { return Ok(BTreeMap::new()); } - let stdout = - run_command_for_stdout(["npm", "list", "--global", "--json"], Perms::Same, StdErr::Show)?; + let stdout = run_command_for_stdout( + ["npm", "list", "--global", "--json"], + Perms::Same, + StdErr::Show, + )?; let value: Value = serde_json::from_str(&stdout)?; let object = value.as_object().ok_or(eyre!("json should be an object"))?; @@ -125,7 +128,11 @@ impl Backend for Npm { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/pipx.rs b/src/backends/pipx.rs index ac610f91..36e5ac32 100644 --- a/src/backends/pipx.rs +++ b/src/backends/pipx.rs @@ -112,7 +112,11 @@ impl Backend for Pipx { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/pnpm.rs b/src/backends/pnpm.rs index 2708bbc0..4b284ccd 100644 --- a/src/backends/pnpm.rs +++ b/src/backends/pnpm.rs @@ -47,8 +47,11 @@ impl Backend for Pnpm { return Ok(BTreeMap::new()); } - let stdout = - run_command_for_stdout(["pnpm", "list", "--global", "--json"], Perms::Same, StdErr::Show)?; + let stdout = run_command_for_stdout( + ["pnpm", "list", "--global", "--json"], + Perms::Same, + StdErr::Show, + )?; let value: Value = serde_json::from_str(&stdout)?; let first_object = value.as_array().ok_or(eyre!("json should be an array"))?[0] @@ -128,7 +131,11 @@ impl Backend for Pnpm { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/scoop.rs b/src/backends/scoop.rs index a057f60e..661fdca0 100644 --- a/src/backends/scoop.rs +++ b/src/backends/scoop.rs @@ -129,7 +129,11 @@ impl Backend for Scoop { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/snap.rs b/src/backends/snap.rs index 83674717..a83434f5 100644 --- a/src/backends/snap.rs +++ b/src/backends/snap.rs @@ -150,7 +150,11 @@ impl Backend for Snap { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/uv.rs b/src/backends/uv.rs index 47fe5e0b..796adf07 100644 --- a/src/backends/uv.rs +++ b/src/backends/uv.rs @@ -127,7 +127,11 @@ impl Backend for Uv { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/vscode.rs b/src/backends/vscode.rs index e7685225..df92dd37 100644 --- a/src/backends/vscode.rs +++ b/src/backends/vscode.rs @@ -142,7 +142,11 @@ impl Backend for VsCode { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/winget.rs b/src/backends/winget.rs index f7548563..cc3d8d23 100644 --- a/src/backends/winget.rs +++ b/src/backends/winget.rs @@ -147,7 +147,11 @@ impl Backend for WinGet { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/xbps.rs b/src/backends/xbps.rs index d6468e96..3c0e94cd 100644 --- a/src/backends/xbps.rs +++ b/src/backends/xbps.rs @@ -47,8 +47,11 @@ impl Backend for Xbps { return Ok(BTreeMap::new()); } - let stdout = - run_command_for_stdout(["xbps-query", "--list-manual-pkgs"], Perms::Same, StdErr::Show)?; + let stdout = run_command_for_stdout( + ["xbps-query", "--list-manual-pkgs"], + Perms::Same, + StdErr::Show, + )?; // Removes the package version from output let re = Regex::new(r"-[^-]*$")?; @@ -149,7 +152,11 @@ impl Backend for Xbps { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/yarn.rs b/src/backends/yarn.rs index 36d1ab16..924a5c09 100644 --- a/src/backends/yarn.rs +++ b/src/backends/yarn.rs @@ -142,7 +142,11 @@ impl Backend for Yarn { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else { diff --git a/src/backends/zypper.rs b/src/backends/zypper.rs index e3c8afaa..5aff00cb 100644 --- a/src/backends/zypper.rs +++ b/src/backends/zypper.rs @@ -147,7 +147,11 @@ impl Backend for Zypper { Ok(BTreeMap::new()) } - fn add_repos(repos: &BTreeMap, _: bool, _: &Self::Config) -> Result<()> { + fn add_repos( + repos: &BTreeMap, + _: bool, + _: &Self::Config, + ) -> Result<()> { if repos.is_empty() { Ok(()) } else {