Resolves clippy errors, please review!!! (#60)
This commit is contained in:
@@ -125,7 +125,7 @@ impl Distribution {
|
||||
fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), String::from("Sudo required"))?;
|
||||
|
||||
ctx.run_type().execute(sudo).args(&["brl", "update"]);
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]);
|
||||
|
||||
let output = Command::new("brl").arg("list").output()?;
|
||||
debug!("brl list: {:?} {:?}", output.stdout, output.stderr);
|
||||
@@ -171,7 +171,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
};
|
||||
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command
|
||||
.arg(which("dnf").unwrap_or_else(|| Path::new("yum").to_path_buf()))
|
||||
.arg(if ctx.config().redhat_distro_sync() {
|
||||
@@ -198,7 +198,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(&sudo).args(&["brl", "update"]).check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -208,11 +208,11 @@ fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(&sudo).args(&["zypper", "refresh"]).check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["zypper", "refresh"]).check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["zypper", "dist-upgrade"])
|
||||
.execute(sudo)
|
||||
.args(["zypper", "dist-upgrade"])
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
@@ -223,9 +223,9 @@ fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
|
||||
command.arg(which("dnf").unwrap().to_path_buf()).arg("upgrade");
|
||||
command.arg(&which("dnf").unwrap()).arg("upgrade");
|
||||
|
||||
if let Some(args) = ctx.config().dnf_arguments() {
|
||||
command.args(args.split_whitespace());
|
||||
@@ -245,15 +245,15 @@ fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
command.args(&["xbps-install", "-Su", "xbps"]);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.args(["xbps-install", "-Su", "xbps"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.check_run()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
command.args(&["xbps-install", "-u"]);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.args(["xbps-install", "-u"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
@@ -270,13 +270,13 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
if let Some(layman) = which("layman") {
|
||||
run_type.execute(&sudo).arg(layman).args(&["-s", "ALL"]).check_run()?;
|
||||
run_type.execute(sudo).arg(layman).args(["-s", "ALL"]).check_run()?;
|
||||
}
|
||||
|
||||
println!("Syncing portage");
|
||||
run_type
|
||||
.execute(&sudo)
|
||||
.args(&["emerge", "--sync"])
|
||||
.execute(sudo)
|
||||
.args(["emerge", "--sync"])
|
||||
.args(
|
||||
ctx.config()
|
||||
.emerge_sync_flags()
|
||||
@@ -286,11 +286,11 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
.check_run()?;
|
||||
|
||||
if let Some(eix_update) = which("eix-update") {
|
||||
run_type.execute(&sudo).arg(eix_update).check_run()?;
|
||||
run_type.execute(sudo).arg(eix_update).check_run()?;
|
||||
}
|
||||
|
||||
run_type
|
||||
.execute(&sudo)
|
||||
.execute(sudo)
|
||||
.arg("emerge")
|
||||
.args(
|
||||
ctx.config()
|
||||
@@ -314,10 +314,10 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let is_nala = apt.ends_with("nala");
|
||||
if !is_nala {
|
||||
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("update").check_run()?;
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.arg(&apt);
|
||||
if is_nala {
|
||||
command.arg("upgrade");
|
||||
@@ -333,9 +333,9 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&sudo).arg(&apt).arg("clean").check_run()?;
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("clean").check_run()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.arg(&apt).arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
@@ -366,7 +366,7 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(&sudo).args(&["eopkg", "upgrade"]).check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["eopkg", "upgrade"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -396,7 +396,7 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
ctx.run_type().execute(&sudo).args(&["swupd", "update"]).check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["swupd", "update"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -406,28 +406,25 @@ fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(&sudo).args(&["cave", "sync"]).check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["cave", "sync"]).check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
|
||||
.execute(sudo)
|
||||
.args(["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["cave", "purge", "-x"])
|
||||
.check_run()?;
|
||||
ctx.run_type().execute(sudo).args(["cave", "purge", "-x"]).check_run()?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["cave", "fix-linkage", "-x", "--", "-Cs"])
|
||||
.execute(sudo)
|
||||
.args(["cave", "fix-linkage", "-x", "--", "-Cs"])
|
||||
.check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["eclectic", "config", "interactive"])
|
||||
.execute(sudo)
|
||||
.args(["eclectic", "config", "interactive"])
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
@@ -439,14 +436,14 @@ fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
|
||||
fn upgrade_nixos(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"])
|
||||
.execute(sudo)
|
||||
.args(["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"])
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(&sudo)
|
||||
.args(&["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
|
||||
.execute(sudo)
|
||||
.args(["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
|
||||
.check_run()?;
|
||||
}
|
||||
} else {
|
||||
@@ -465,8 +462,8 @@ fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let pkcon = which("pkcon").unwrap();
|
||||
// pkcon ignores update with update and refresh provided together
|
||||
ctx.run_type().execute(&sudo).arg(&pkcon).arg("refresh").check_run()?;
|
||||
let mut exe = ctx.run_type().execute(&sudo);
|
||||
ctx.run_type().execute(sudo).arg(&pkcon).arg("refresh").check_run()?;
|
||||
let mut exe = ctx.run_type().execute(sudo);
|
||||
let cmd = exe.arg(&pkcon).arg("update");
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-y");
|
||||
@@ -492,7 +489,7 @@ pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
|
||||
|
||||
print_separator("Check for needed restarts");
|
||||
|
||||
run_type.execute(&sudo).arg(needrestart).check_run()?;
|
||||
run_type.execute(sudo).arg(needrestart).check_run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -552,7 +549,7 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type.execute(&sudo).arg(&flatpak).args(&update_args).check_run()?;
|
||||
run_type.execute(sudo).arg(&flatpak).args(&update_args).check_run()?;
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||
if yes {
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::utils::{require, PathExt};
|
||||
use crate::Step;
|
||||
use anyhow::Result;
|
||||
use directories::BaseDirs;
|
||||
use home;
|
||||
use ini::Ini;
|
||||
use log::debug;
|
||||
use std::fs;
|
||||
@@ -90,16 +91,16 @@ pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||
|
||||
let version_str = run_type
|
||||
.execute(&fish)
|
||||
.args(&["-c", "fisher --version"])
|
||||
.args(["-c", "fisher --version"])
|
||||
.check_output()?;
|
||||
debug!("Fisher version: {}", version_str);
|
||||
|
||||
if version_str.starts_with("fisher version 3.") {
|
||||
// v3 - see https://github.com/topgrade-rs/topgrade/pull/37#issuecomment-1283844506
|
||||
run_type.execute(&fish).args(&["-c", "fisher"]).check_run()
|
||||
run_type.execute(&fish).args(["-c", "fisher"]).check_run()
|
||||
} else {
|
||||
// v4
|
||||
run_type.execute(&fish).args(&["-c", "fisher update"]).check_run()
|
||||
run_type.execute(&fish).args(["-c", "fisher update"]).check_run()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ pub fn run_bashit(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
ctx.run_type()
|
||||
.execute("bash")
|
||||
.args(&["-lic", &format!("bash-it update {}", ctx.config().bashit_branch())])
|
||||
.args(["-lic", &format!("bash-it update {}", ctx.config().bashit_branch())])
|
||||
.check_run()
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("oh-my-fish");
|
||||
|
||||
ctx.run_type().execute(&fish).args(&["-c", "omf update"]).check_run()
|
||||
ctx.run_type().execute(&fish).args(["-c", "omf update"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_pkgin(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -153,7 +154,7 @@ pub fn run_fish_plug(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("fish-plug");
|
||||
|
||||
ctx.run_type().execute(&fish).args(&["-c", "plug update"]).check_run()
|
||||
ctx.run_type().execute(&fish).args(["-c", "plug update"]).check_run()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "macos")))]
|
||||
@@ -164,7 +165,7 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
"Desktop doest not appear to be gnome".to_string(),
|
||||
)?;
|
||||
let output = Command::new("gdbus")
|
||||
.args(&[
|
||||
.args([
|
||||
"call",
|
||||
"--session",
|
||||
"--dest",
|
||||
@@ -185,7 +186,7 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
ctx.run_type()
|
||||
.execute(gdbus)
|
||||
.args(&[
|
||||
.args([
|
||||
"call",
|
||||
"--session",
|
||||
"--dest",
|
||||
@@ -215,7 +216,7 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
||||
variant.execute(run_type).arg("update").check_run()?;
|
||||
variant
|
||||
.execute(run_type)
|
||||
.args(&["upgrade", "--ignore-pinned", "--formula"])
|
||||
.args(["upgrade", "--ignore-pinned", "--formula"])
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
@@ -280,7 +281,7 @@ pub fn run_guix(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Guix");
|
||||
|
||||
if should_upgrade {
|
||||
return run_type.execute(&guix).args(&["package", "-u"]).check_run();
|
||||
return run_type.execute(&guix).args(["package", "-u"]).check_run();
|
||||
}
|
||||
Err(SkipStep(String::from("Guix Pull Failed, Skipping")).into())
|
||||
}
|
||||
@@ -289,14 +290,14 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
let nix = require("nix")?;
|
||||
let nix_channel = require("nix-channel")?;
|
||||
let nix_env = require("nix-env")?;
|
||||
let profile_path = match env::home_dir() {
|
||||
let profile_path = match home::home_dir() {
|
||||
Some(home) => Path::new(&home).join(".nix-profile"),
|
||||
None => Path::new("/nix/var/nix/profiles/per-user/default").into(),
|
||||
};
|
||||
debug!("nix profile: {:?}", profile_path);
|
||||
let manifest_json_path = profile_path.join("manifest.json");
|
||||
|
||||
let output = Command::new(&nix_env).args(&["--query", "nix"]).check_output();
|
||||
let output = Command::new(&nix_env).args(["--query", "nix"]).check_output();
|
||||
debug!("nix-env output: {:?}", output);
|
||||
let should_self_upgrade = output.is_ok();
|
||||
|
||||
@@ -367,7 +368,7 @@ pub fn run_asdf(run_type: RunType) -> Result<()> {
|
||||
return Err(TopgradeError::ProcessFailed(e).into());
|
||||
}
|
||||
}
|
||||
run_type.execute(&asdf).args(&["plugin", "update", "--all"]).check_run()
|
||||
run_type.execute(&asdf).args(["plugin", "update", "--all"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_home_manager(run_type: RunType) -> Result<()> {
|
||||
@@ -421,30 +422,27 @@ pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Res
|
||||
let cmd_selfupdate = format!("source {} && sdk selfupdate", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(&["-c", cmd_selfupdate.as_str()])
|
||||
.args(["-c", cmd_selfupdate.as_str()])
|
||||
.check_run()?;
|
||||
}
|
||||
|
||||
let cmd_update = format!("source {} && sdk update", &sdkman_init_path);
|
||||
run_type.execute(&bash).args(&["-c", cmd_update.as_str()]).check_run()?;
|
||||
run_type.execute(&bash).args(["-c", cmd_update.as_str()]).check_run()?;
|
||||
|
||||
let cmd_upgrade = format!("source {} && sdk upgrade", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(&["-c", cmd_upgrade.as_str()])
|
||||
.check_run()?;
|
||||
run_type.execute(&bash).args(["-c", cmd_upgrade.as_str()]).check_run()?;
|
||||
|
||||
if cleanup {
|
||||
let cmd_flush_archives = format!("source {} && sdk flush archives", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(&["-c", cmd_flush_archives.as_str()])
|
||||
.args(["-c", cmd_flush_archives.as_str()])
|
||||
.check_run()?;
|
||||
|
||||
let cmd_flush_temp = format!("source {} && sdk flush temp", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(&["-c", cmd_flush_temp.as_str()])
|
||||
.args(["-c", cmd_flush_temp.as_str()])
|
||||
.check_run()?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user