Resolves clippy errors, please review!!! (#60)

This commit is contained in:
Thomas Schönauer
2022-10-23 11:34:30 +00:00
committed by GitHub
parent 6000124062
commit 347372ca71
19 changed files with 147 additions and 140 deletions

View File

@@ -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()?;
}