Support rust 1.51.0 (#789)

This commit is contained in:
Roey Darwish Dror
2021-10-28 22:05:35 +03:00
committed by GitHub
parent 6ef5423d68
commit 539b267eef
23 changed files with 152 additions and 124 deletions

View File

@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.51.0
profile: minimal
override: true
components: rustfmt, clippy

View File

@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.51.0
profile: minimal
override: true
components: rustfmt, clippy

View File

@@ -300,7 +300,7 @@ impl ConfigFile {
})?;
if let Some(ref mut paths) = &mut result.git_repos {
for path in paths {
for path in paths.iter_mut() {
let expanded = shellexpand::tilde::<&str>(&path.as_ref()).into_owned();
debug!("Path {} expanded to {}", path, expanded);
*path = expanded;
@@ -308,7 +308,7 @@ impl ConfigFile {
}
if let Some(paths) = result.git.as_mut().and_then(|git| git.repos.as_mut()) {
for path in paths {
for path in paths.iter_mut() {
let expanded = shellexpand::tilde::<&str>(&path.as_ref()).into_owned();
debug!("Path {} expanded to {}", path, expanded);
*path = expanded;

View File

@@ -410,10 +410,16 @@ fn run() -> Result<()> {
print_info("\n(R)eboot\n(S)hell\n(Q)uit");
loop {
match get_key() {
Ok(Key::Char('s' | 'S')) => run_shell(),
Ok(Key::Char('r' | 'R')) => reboot(),
Ok(Key::Char('q' | 'Q')) => (),
_ => continue,
Ok(Key::Char('s')) | Ok(Key::Char('S')) => {
run_shell();
}
Ok(Key::Char('r')) | Ok(Key::Char('R')) => {
reboot();
}
Ok(Key::Char('q')) | Ok(Key::Char('Q')) => (),
_ => {
continue;
}
}
break;
}

View File

@@ -9,7 +9,10 @@ pub enum StepResult {
impl StepResult {
pub fn failed(&self) -> bool {
matches!(self, StepResult::Failure)
match self {
StepResult::Success | StepResult::Ignored | StepResult::Skipped(_) => false,
StepResult::Failure => true,
}
}
}

View File

@@ -58,7 +58,7 @@ impl Emacs {
fn update_doom(doom: &Path, run_type: RunType) -> Result<()> {
print_separator("Doom Emacs");
run_type.execute(doom).args(["-y", "upgrade"]).check_run()
run_type.execute(doom).args(&["-y", "upgrade"]).check_run()
}
pub fn upgrade(&self, run_type: RunType) -> Result<()> {
@@ -76,7 +76,7 @@ impl Emacs {
let mut command = run_type.execute(&emacs);
command
.args(["--batch", "--debug-init", "-l"])
.args(&["--batch", "--debug-init", "-l"])
.arg(init_file)
.arg("--eval");

View File

@@ -49,7 +49,7 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
ctx.run_type()
.execute(cargo_update)
.args(["install-update", "--git", "--all"])
.args(&["install-update", "--git", "--all"])
.check_run()
}
@@ -106,7 +106,7 @@ pub fn run_sheldon(ctx: &ExecutionContext) -> Result<()> {
print_separator("Sheldon");
ctx.run_type().execute(&sheldon).args(["lock", "--update"]).check_run()
ctx.run_type().execute(&sheldon).args(&["lock", "--update"]).check_run()
}
pub fn run_fossil(run_type: RunType) -> Result<()> {
@@ -114,7 +114,7 @@ pub fn run_fossil(run_type: RunType) -> Result<()> {
print_separator("Fossil");
run_type.execute(&fossil).args(["all", "sync"]).check_run()
run_type.execute(&fossil).args(&["all", "sync"]).check_run()
}
pub fn run_micro(run_type: RunType) -> Result<()> {
@@ -122,7 +122,7 @@ pub fn run_micro(run_type: RunType) -> Result<()> {
print_separator("micro");
let stdout = run_type.execute(&micro).args(["-plugin", "update"]).string_output()?;
let stdout = run_type.execute(&micro).args(&["-plugin", "update"]).string_output()?;
std::io::stdout().write_all(stdout.as_bytes())?;
if stdout.contains("Nothing to install / update") || stdout.contains("One or more plugins installed") {
@@ -143,7 +143,7 @@ pub fn run_apm(run_type: RunType) -> Result<()> {
print_separator("Atom Package Manager");
run_type.execute(&apm).args(["upgrade", "--confirm=false"]).check_run()
run_type.execute(&apm).args(&["upgrade", "--confirm=false"]).check_run()
}
pub fn run_rustup(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
@@ -152,7 +152,7 @@ pub fn run_rustup(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("rustup");
if rustup.canonicalize()?.is_descendant_of(base_dirs.home_dir()) {
run_type.execute(&rustup).args(["self", "update"]).check_run()?;
run_type.execute(&rustup).args(&["self", "update"]).check_run()?;
}
run_type.execute(&rustup).arg("update").check_run()
@@ -164,8 +164,8 @@ pub fn run_choosenim(ctx: &ExecutionContext) -> Result<()> {
print_separator("choosenim");
let run_type = ctx.run_type();
run_type.execute(&choosenim).args(["update", "self"]).check_run()?;
run_type.execute(&choosenim).args(["update", "stable"]).check_run()
run_type.execute(&choosenim).args(&["update", "self"]).check_run()?;
run_type.execute(&choosenim).args(&["update", "stable"]).check_run()
}
pub fn run_krew_upgrade(run_type: RunType) -> Result<()> {
@@ -173,7 +173,7 @@ pub fn run_krew_upgrade(run_type: RunType) -> Result<()> {
print_separator("Krew");
run_type.execute(&krew).args(["upgrade"]).check_run()
run_type.execute(&krew).args(&["upgrade"]).check_run()
}
pub fn run_gcloud_components_update(run_type: RunType) -> Result<()> {
@@ -183,7 +183,7 @@ pub fn run_gcloud_components_update(run_type: RunType) -> Result<()> {
run_type
.execute(&gcloud)
.args(["components", "update", "--quiet"])
.args(&["components", "update", "--quiet"])
.check_run()
}
@@ -192,7 +192,7 @@ pub fn run_jetpack(run_type: RunType) -> Result<()> {
print_separator("Jetpack");
run_type.execute(&jetpack).args(["global", "update"]).check_run()
run_type.execute(&jetpack).args(&["global", "update"]).check_run()
}
pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> {
@@ -216,7 +216,7 @@ pub fn run_vcpkg_update(run_type: RunType) -> Result<()> {
let vcpkg = utils::require("vcpkg")?;
print_separator("vcpkg");
run_type.execute(&vcpkg).args(["upgrade", "--no-dry-run"]).check_run()
run_type.execute(&vcpkg).args(&["upgrade", "--no-dry-run"]).check_run()
}
pub fn run_pipx_update(run_type: RunType) -> Result<()> {
@@ -236,7 +236,7 @@ pub fn run_pip3_update(run_type: RunType) -> Result<()> {
run_type
.execute(&pip3)
.args(["install", "--upgrade", "--user", "pip"])
.args(&["install", "--upgrade", "--user", "pip"])
.check_run()
}
@@ -287,7 +287,7 @@ pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
c.arg(&tlmgr);
c
};
command.args(["update", "--self", "--all"]);
command.args(&["update", "--self", "--all"]);
command.check_run()
}
@@ -329,7 +329,7 @@ pub fn run_custom_command(name: &str, command: &str, ctx: &ExecutionContext) ->
pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
let composer = utils::require("composer")?;
let composer_home = Command::new(&composer)
.args(["global", "config", "--absolute", "--quiet", "home"])
.args(&["global", "config", "--absolute", "--quiet", "home"])
.check_output()
.map_err(|e| (SkipStep(format!("Error getting the composer directory: {}", e))))
.map(|s| PathBuf::from(s.trim()))?
@@ -367,7 +367,7 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
}
}
let output = Command::new(&composer).args(["global", "update"]).output()?;
let output = Command::new(&composer).args(&["global", "update"]).output()?;
let status = output.status;
if !status.success() {
return Err(TopgradeError::ProcessFailed(status).into());
@@ -388,7 +388,7 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
let dotnet = utils::require("dotnet")?;
let output = Command::new(dotnet).args(["tool", "list", "--global"]).output()?;
let output = Command::new(dotnet).args(&["tool", "list", "--global"]).output()?;
if !output.status.success() {
return Err(SkipStep(format!("dotnet failed with exit code {:?}", output.status)).into());
@@ -411,7 +411,7 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
let package_name = package.split_whitespace().next().unwrap();
ctx.run_type()
.execute("dotnet")
.args(["tool", "update", package_name, "--global"])
.args(&["tool", "update", package_name, "--global"])
.check_run()?;
}
@@ -423,7 +423,7 @@ pub fn run_raco_update(run_type: RunType) -> Result<()> {
print_separator("Racket Package Manager");
run_type.execute(&raco).args(["pkg", "update", "--all"]).check_run()
run_type.execute(&raco).args(&["pkg", "update", "--all"]).check_run()
}
pub fn bin_update(ctx: &ExecutionContext) -> Result<()> {

View File

@@ -53,7 +53,7 @@ async fn pull_repository(repo: String, git: &Path, ctx: &ExecutionContext<'_>) -
command
.stdin(Stdio::null())
.current_dir(&repo)
.args(["pull", "--ff-only"]);
.args(&["pull", "--ff-only"]);
if let Some(extra_arguments) = ctx.config().git_arguments() {
command.args(extra_arguments.split_whitespace());
@@ -61,7 +61,7 @@ async fn pull_repository(repo: String, git: &Path, ctx: &ExecutionContext<'_>) -
let pull_output = command.output().await?;
let submodule_output = AsyncCommand::new(git)
.args(["submodule", "update", "--recursive"])
.args(&["submodule", "update", "--recursive"])
.current_dir(&repo)
.stdin(Stdio::null())
.output()
@@ -81,7 +81,7 @@ async fn pull_repository(repo: String, git: &Path, ctx: &ExecutionContext<'_>) -
Command::new(&git)
.stdin(Stdio::null())
.current_dir(&repo)
.args([
.args(&[
"--no-pager",
"log",
"--no-decorate",
@@ -107,7 +107,7 @@ fn get_head_revision(git: &Path, repo: &str) -> Option<String> {
Command::new(git)
.stdin(Stdio::null())
.current_dir(repo)
.args(["rev-parse", "HEAD"])
.args(&["rev-parse", "HEAD"])
.check_output()
.map(|output| output.trim().to_string())
.map_err(|e| {
@@ -122,7 +122,7 @@ fn has_remotes(git: &Path, repo: &str) -> Option<bool> {
Command::new(git)
.stdin(Stdio::null())
.current_dir(repo)
.args(["remote", "show"])
.args(&["remote", "show"])
.check_output()
.map(|output| output.lines().count() > 0)
.map_err(|e| {
@@ -165,7 +165,7 @@ impl Git {
let output = Command::new(&git)
.stdin(Stdio::null())
.current_dir(path)
.args(["rev-parse", "--show-toplevel"])
.args(&["rev-parse", "--show-toplevel"])
.check_output()
.ok()
.map(|output| output.trim().to_string());

View File

@@ -27,7 +27,7 @@ impl NPM {
#[cfg(target_os = "linux")]
fn root(&self) -> Result<PathBuf> {
Command::new(&self.command)
.args(["root", "-g"])
.args(&["root", "-g"])
.check_output()
.map(|s| PathBuf::from(s.trim()))
}
@@ -37,10 +37,10 @@ impl NPM {
run_type
.execute("sudo")
.arg(&self.command)
.args(["update", "-g"])
.args(&["update", "-g"])
.check_run()?;
} else {
run_type.execute(&self.command).args(["update", "-g"]).check_run()?;
run_type.execute(&self.command).args(&["update", "-g"]).check_run()?;
}
Ok(())
@@ -98,14 +98,14 @@ pub fn pnpm_global_update(ctx: &ExecutionContext) -> Result<()> {
ctx.run_type()
.execute("sudo")
.arg(pnpm)
.args(["update", "-g"])
.args(&["update", "-g"])
.check_run()
} else {
ctx.run_type().execute(&pnpm).args(["update", "-g"]).check_run()
ctx.run_type().execute(&pnpm).args(&["update", "-g"]).check_run()
}
#[cfg(not(target_os = "linux"))]
ctx.run_type().execute(&pnpm).args(["update", "-g"]).check_run()
ctx.run_type().execute(&pnpm).args(&["update", "-g"]).check_run()
}
pub fn deno_upgrade(ctx: &ExecutionContext) -> Result<()> {

View File

@@ -10,7 +10,7 @@ pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
print_separator("DrgaonFly BSD Packages");
run_type
.execute(sudo)
.args(["/usr/local/sbin/pkg", "upgrade"])
.args(&["/usr/local/sbin/pkg", "upgrade"])
.check_run()
}
@@ -18,7 +18,7 @@ pub fn audit_packages(sudo: &Option<PathBuf>) -> Result<()> {
if let Some(sudo) = sudo {
println!();
Command::new(sudo)
.args(["/usr/local/sbin/pkg", "audit", "-Fr"])
.args(&["/usr/local/sbin/pkg", "audit", "-Fr"])
.spawn()?
.wait()?;
}

View File

@@ -10,21 +10,21 @@ pub fn upgrade_freebsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
print_separator("FreeBSD Update");
run_type
.execute(sudo)
.args(["/usr/sbin/freebsd-update", "fetch", "install"])
.args(&["/usr/sbin/freebsd-update", "fetch", "install"])
.check_run()
}
pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
let sudo = require_option(sudo, String::from("No sudo detected"))?;
print_separator("FreeBSD Packages");
run_type.execute(sudo).args(["/usr/sbin/pkg", "upgrade"]).check_run()
run_type.execute(sudo).args(&["/usr/sbin/pkg", "upgrade"]).check_run()
}
pub fn audit_packages(sudo: &Option<PathBuf>) -> Result<()> {
if let Some(sudo) = sudo {
println!();
Command::new(sudo)
.args(["/usr/sbin/pkg", "audit", "-Fr"])
.args(&["/usr/sbin/pkg", "audit", "-Fr"])
.spawn()?
.wait()?;
}

View File

@@ -46,12 +46,12 @@ impl Distribution {
Ok(match id {
Some("alpine") => Distribution::Alpine,
Some("centos" | "rhel" | "ol") => Distribution::CentOS,
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
Some("clear-linux-os") => Distribution::ClearLinux,
Some("fedora") => Distribution::Fedora,
Some("void") => Distribution::Void,
Some("debian" | "pureos") => Distribution::Debian,
Some("arch" | "anarchy" | "manjaro-arm" | "garuda" | "artix") => Distribution::Arch,
Some("debian") | Some("pureos") => Distribution::Debian,
Some("arch") | Some("anarchy") | Some("manjaro-arm") | Some("garuda") | Some("artix") => Distribution::Arch,
Some("solus") => Distribution::Solus,
Some("gentoo") => Distribution::Gentoo,
Some("exherbo") => Distribution::Exherbo,
@@ -179,12 +179,12 @@ fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/zypper", "refresh"])
.args(&["/usr/bin/zypper", "refresh"])
.check_run()?;
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/zypper", "dist-upgrade"])
.args(&["/usr/bin/zypper", "dist-upgrade"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
@@ -197,12 +197,12 @@ fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/xbps-install", "-Su", "xbps"])
.args(&["/usr/bin/xbps-install", "-Su", "xbps"])
.check_run()?;
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/xbps-install", "-u"])
.args(&["/usr/bin/xbps-install", "-u"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
@@ -216,13 +216,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(["/usr/bin/emerge", "--sync"])
.args(&["/usr/bin/emerge", "--sync"])
.args(
ctx.config()
.emerge_sync_flags()
@@ -288,7 +288,7 @@ fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/eopkg", "upgrade"])
.args(&["/usr/bin/eopkg", "upgrade"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
@@ -310,7 +310,7 @@ fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = &ctx.sudo() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/swupd", "update"])
.args(&["/usr/bin/swupd", "update"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
@@ -323,29 +323,29 @@ fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/cave", "sync"])
.args(&["/usr/bin/cave", "sync"])
.check_run()?;
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
.args(&["/usr/bin/cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
.check_run()?;
if ctx.config().cleanup() {
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/cave", "purge", "-x"])
.args(&["/usr/bin/cave", "purge", "-x"])
.check_run()?;
}
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/cave", "fix-linkage", "-x", "--", "-Cs"])
.args(&["/usr/bin/cave", "fix-linkage", "-x", "--", "-Cs"])
.check_run()?;
ctx.run_type()
.execute(&sudo)
.args(["/usr/bin/eclectic", "config", "interactive"])
.args(&["/usr/bin/eclectic", "config", "interactive"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
@@ -358,13 +358,13 @@ 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"])
.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"])
.args(&["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
.check_run()?;
}
} else {
@@ -450,7 +450,7 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
run_type
.execute(&flatpak)
.args(["update", "--user", "-y"])
.args(&["update", "--user", "-y"])
.check_run()?;
print_separator("Flatpak System Packages");
@@ -458,12 +458,12 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
run_type
.execute(sudo)
.arg(flatpak)
.args(["update", "--system", "-y"])
.args(&["update", "--system", "-y"])
.check_run()
} else {
run_type
.execute(&flatpak)
.args(["update", "--system", "-y"])
.args(&["update", "--system", "-y"])
.check_run()
}
}

View File

@@ -10,15 +10,15 @@ pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
require("port")?;
let sudo = ctx.sudo().as_ref().unwrap();
print_separator("MacPorts");
ctx.run_type().execute(sudo).args(["port", "selfupdate"]).check_run()?;
ctx.run_type().execute(sudo).args(&["port", "selfupdate"]).check_run()?;
ctx.run_type()
.execute(sudo)
.args(["port", "-u", "upgrade", "outdated"])
.args(&["port", "-u", "upgrade", "outdated"])
.check_run()?;
if ctx.config().cleanup() {
ctx.run_type()
.execute(sudo)
.args(["port", "-N", "reclaim"])
.args(&["port", "-N", "reclaim"])
.check_run()?;
}
@@ -58,7 +58,7 @@ pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
}
let mut command = ctx.run_type().execute("softwareupdate");
command.args(["--install", "--all"]);
command.args(&["--install", "--all"]);
if should_ask {
command.arg("--no-scan");

View File

@@ -75,7 +75,7 @@ pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("Fisher");
run_type.execute(&fish).args(["-c", "fisher update"]).check_run()
run_type.execute(&fish).args(&["-c", "fisher update"]).check_run()
}
pub fn run_bashit(ctx: &ExecutionContext) -> Result<()> {
@@ -85,7 +85,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()
}
@@ -98,7 +98,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<()> {
@@ -128,7 +128,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()
}
pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
@@ -162,7 +162,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() {
@@ -180,19 +180,19 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
let cask_upgrade_exists = variant
.execute(RunType::Wet)
.args(["--repository", "buo/cask-upgrade"])
.args(&["--repository", "buo/cask-upgrade"])
.check_output()
.map(|p| Path::new(p.trim()).exists())?;
let mut brew_args = vec![];
if cask_upgrade_exists {
brew_args.extend(["cu", "-y"]);
brew_args.extend(&["cu", "-y"]);
if ctx.config().brew_cask_greedy() {
brew_args.push("-a");
}
} else {
brew_args.extend(["upgrade", "--cask"]);
brew_args.extend(&["upgrade", "--cask"]);
if ctx.config().brew_cask_greedy() {
brew_args.push("--greedy");
}
@@ -229,7 +229,10 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
if multi_user {
if let Some(sudo) = ctx.sudo() {
run_type.execute(&sudo).args(["-i", "nix", "upgrade-nix"]).check_run()?;
run_type
.execute(&sudo)
.args(&["-i", "nix", "upgrade-nix"])
.check_run()?;
} else {
print_warning("Need sudo to upgrade Nix");
}
@@ -259,7 +262,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<()> {
@@ -297,20 +300,32 @@ pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Res
print_separator("SDKMAN!");
let cmd_selfupdate = format!("source {} && sdk selfupdate", &sdkman_init_path);
run_type.execute(&bash).args(["-c", &cmd_selfupdate]).check_run()?;
run_type
.execute(&bash)
.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]).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]).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]).check_run()?;
run_type
.execute(&bash)
.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]).check_run()?;
run_type
.execute(&bash)
.args(&["-c", cmd_flush_temp.as_str()])
.check_run()?;
}
Ok(())

View File

@@ -40,7 +40,7 @@ pub fn run_winget(ctx: &ExecutionContext) -> Result<()> {
print_separator("winget");
ctx.run_type().execute(&winget).args(["upgrade", "--all"]).check_run()
ctx.run_type().execute(&winget).args(&["upgrade", "--all"]).check_run()
}
pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
@@ -48,11 +48,11 @@ pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
print_separator("Scoop");
run_type.execute(&scoop).args(["update"]).check_run()?;
run_type.execute(&scoop).args(["update", "*"]).check_run()?;
run_type.execute(&scoop).args(&["update"]).check_run()?;
run_type.execute(&scoop).args(&["update", "*"]).check_run()?;
if cleanup {
run_type.execute(&scoop).args(["cleanup", "*"]).check_run()?;
run_type.execute(&scoop).args(&["cleanup", "*"]).check_run()?;
}
Ok(())
@@ -61,13 +61,13 @@ pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
pub fn run_wsl_topgrade(ctx: &ExecutionContext) -> Result<()> {
let wsl = require("wsl")?;
let topgrade = Command::new(&wsl)
.args(["bash", "-lc", "which topgrade"])
.args(&["bash", "-lc", "which topgrade"])
.check_output()
.map_err(|_| SkipStep(String::from("Could not find Topgrade installed in WSL")))?;
let mut command = ctx.run_type().execute(&wsl);
command
.args(["bash", "-c"])
.args(&["bash", "-c"])
.arg(format!("TOPGRADE_PREFIX=WSL exec {}", topgrade));
if ctx.config().yes() {
@@ -94,7 +94,7 @@ pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {
}
pub fn reboot() {
Command::new("shutdown").args(["/R", "/T", "0"]).spawn().ok();
Command::new("shutdown").args(&["/R", "/T", "0"]).spawn().ok();
}
pub fn insert_startup_scripts(ctx: &ExecutionContext, git_repos: &mut Repositories) -> Result<()> {

View File

@@ -23,7 +23,7 @@ impl Powershell {
let profile = path.as_ref().and_then(|path| {
Command::new(path)
.args(["-NoProfile", "-Command", "Split-Path $profile"])
.args(&["-NoProfile", "-Command", "Split-Path $profile"])
.check_output()
.map(|output| PathBuf::from(output.trim()))
.and_then(|p| p.require())
@@ -44,7 +44,7 @@ impl Powershell {
#[cfg(windows)]
pub fn has_module(powershell: &Path, command: &str) -> bool {
Command::new(&powershell)
.args([
.args(&[
"-NoProfile",
"-Command",
&format!("Get-Module -ListAvailable {}", command),
@@ -76,7 +76,7 @@ impl Powershell {
println!("Updating modules...");
ctx.run_type()
.execute(&powershell)
.args(["-NoProfile", "-Command", &cmd.join(" ")])
.args(&["-NoProfile", "-Command", &cmd.join(" ")])
.check_run()
}
@@ -103,7 +103,7 @@ impl Powershell {
};
command
.args([
.args(&[
"-NoProfile",
"-Command",
&format!(

View File

@@ -17,7 +17,7 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
}
let env = format!("TOPGRADE_PREFIX={}", hostname);
args.extend(["env", &env, "$SHELL", "-lc", topgrade]);
args.extend(&["env", &env, "$SHELL", "-lc", topgrade]);
if ctx.config().yes() {
args.push("-y");
@@ -45,7 +45,7 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
}
let env = format!("TOPGRADE_PREFIX={}", hostname);
args.extend(["env", &env, "$SHELL", "-lc", topgrade]);
args.extend(&["env", &env, "$SHELL", "-lc", topgrade]);
if ctx.config().yes() {
args.push("-y");

View File

@@ -110,7 +110,7 @@ impl<'a> TemporaryPowerOn<'a> {
ctx.run_type()
.execute(vagrant)
.args([subcommand, &vagrant_box.name])
.args(&[subcommand, &vagrant_box.name])
.current_dir(vagrant_box.path.clone())
.check_run()?;
Ok(TemporaryPowerOn {
@@ -137,7 +137,7 @@ impl<'a> Drop for TemporaryPowerOn<'a> {
self.ctx
.run_type()
.execute(self.vagrant)
.args([subcommand, &self.vagrant_box.name])
.args(&[subcommand, &self.vagrant_box.name])
.current_dir(self.vagrant_box.path.clone())
.check_run()
.ok();
@@ -195,6 +195,6 @@ pub fn topgrade_vagrant_box(ctx: &ExecutionContext, vagrant_box: &VagrantBox) ->
ctx.run_type()
.execute(&vagrant.path)
.current_dir(&vagrant_box.path)
.args(["ssh", "-c", &command])
.args(&["ssh", "-c", &command])
.check_run()
}

View File

@@ -49,7 +49,7 @@ impl Tmux {
fn has_session(&self, session_name: &str) -> Result<bool, io::Error> {
Ok(self
.build()
.args(["has-session", "-t", session_name])
.args(&["has-session", "-t", session_name])
.output()?
.status
.success())
@@ -58,7 +58,7 @@ impl Tmux {
fn new_session(&self, session_name: &str) -> Result<bool, io::Error> {
Ok(self
.build()
.args(["new-session", "-d", "-s", session_name, "-n", "dummy"])
.args(&["new-session", "-d", "-s", session_name, "-n", "dummy"])
.spawn()?
.wait()?
.success())
@@ -66,7 +66,7 @@ impl Tmux {
fn run_in_session(&self, command: &str) -> Result<()> {
self.build()
.args(["new-window", "-t", "topgrade", command])
.args(&["new-window", "-t", "topgrade", command])
.spawn()?
.wait()?
.check()?;
@@ -94,12 +94,12 @@ pub fn run_in_tmux(args: &Option<String>) -> ! {
tmux.run_in_session(&command).expect("Error running topgrade in tmux");
tmux.build()
.args(["kill-window", "-t", "topgrade:dummy"])
.args(&["kill-window", "-t", "topgrade:dummy"])
.output()
.expect("Error killing the dummy tmux window");
if env::var("TMUX").is_err() {
let err = tmux.build().args(["attach", "-t", "topgrade"]).exec();
let err = tmux.build().args(&["attach", "-t", "topgrade"]).exec();
panic!("{:?}", err);
} else {
println!("Topgrade launched in a new tmux session");
@@ -110,7 +110,7 @@ pub fn run_in_tmux(args: &Option<String>) -> ! {
pub fn run_command(ctx: &ExecutionContext, command: &str) -> Result<()> {
Tmux::new(ctx.config().tmux_arguments())
.build()
.args(["new-window", "-a", "-t", "topgrade:1", command])
.args(&["new-window", "-a", "-t", "topgrade:1", command])
.env_remove("TMUX")
.spawn()?
.wait()?

View File

@@ -48,9 +48,9 @@ fn upgrade(vim: &Path, vimrc: &Path, ctx: &ExecutionContext) -> Result<()> {
let output = ctx
.run_type()
.execute(&vim)
.arg("-u")
.args(&["-u"])
.arg(vimrc)
.args(["-U", "NONE", "-V1", "-nNesS"])
.args(&["-U", "NONE", "-V1", "-nNesS"])
.arg(tempfile.path())
.output()?;

View File

@@ -19,7 +19,7 @@ pub fn run_zr(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("zr");
let cmd = format!("source {} && zr --update", zshrc(base_dirs).display());
run_type.execute(zsh).args(["-l", "-c", &cmd]).check_run()
run_type.execute(zsh).args(&["-l", "-c", cmd.as_str()]).check_run()
}
pub fn zshrc(base_dirs: &BaseDirs) -> PathBuf {
@@ -48,7 +48,7 @@ pub fn run_antigen(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("antigen");
let cmd = format!("source {} && antigen selfupdate && antigen update", zshrc.display());
run_type.execute(zsh).args(["-l", "-c", &cmd]).check_run()
run_type.execute(zsh).args(&["-l", "-c", cmd.as_str()]).check_run()
}
pub fn run_zplug(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
@@ -62,7 +62,7 @@ pub fn run_zplug(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("zplug");
run_type.execute(zsh).args(["-i", "-c", "zplug update"]).check_run()
run_type.execute(zsh).args(&["-i", "-c", "zplug update"]).check_run()
}
pub fn run_zinit(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
@@ -77,7 +77,7 @@ pub fn run_zinit(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
print_separator("zinit");
let cmd = format!("source {} && zinit self-update && zinit update --all", zshrc.display(),);
run_type.execute(zsh).args(["-i", "-c", &cmd]).check_run()
run_type.execute(zsh).args(&["-i", "-c", cmd.as_str()]).check_run()
}
pub fn run_zim(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
@@ -85,7 +85,7 @@ pub fn run_zim(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
env::var("ZIM_HOME")
.or_else(|_| {
Command::new("zsh")
.args(["-c", "[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}"])
.args(&["-c", "[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}"])
.check_output()
})
.map(PathBuf::from)
@@ -96,7 +96,7 @@ pub fn run_zim(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
run_type
.execute(zsh)
.args(["-i", "-c", "zimfw upgrade && zimfw update"])
.args(&["-i", "-c", "zimfw upgrade && zimfw update"])
.check_run()
}
@@ -109,7 +109,7 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> {
let custom_dir = env::var::<_>("ZSH_CUSTOM")
.or_else(|_| {
Command::new("zsh")
.args(["-c", "test $ZSH_CUSTOM && echo -n $ZSH_CUSTOM"])
.args(&["-c", "test $ZSH_CUSTOM && echo -n $ZSH_CUSTOM"])
.check_output()
})
.map(PathBuf::from)

View File

@@ -97,7 +97,7 @@ impl Terminal {
if let Some(timeout) = timeout {
command.arg("-t");
command.arg(format!("{}", timeout.as_millis()));
command.args(["-a", "Topgrade"]);
command.args(&["-a", "Topgrade"]);
command.arg(message.as_ref());
}
command.output().ok();
@@ -229,18 +229,18 @@ impl Terminal {
let answer = loop {
match self.term.read_key() {
Ok(Key::Char('y' | 'Y')) => break Ok(true),
Ok(Key::Char('s' | 'S')) => {
Ok(Key::Char('y')) | Ok(Key::Char('Y')) => break Ok(true),
Ok(Key::Char('s')) | Ok(Key::Char('S')) => {
println!("\n\nDropping you to shell. Fix what you need and then exit the shell.\n");
run_shell();
break Ok(true);
}
Ok(Key::Char('n' | 'N') | Key::Enter) => break Ok(false),
Ok(Key::Char('n')) | Ok(Key::Char('N')) | Ok(Key::Enter) => break Ok(false),
Err(e) => {
error!("Error reading from terminal: {}", e);
break Ok(false);
}
Ok(Key::Char('q' | 'Q')) => return Err(io::Error::from(io::ErrorKind::Interrupted)),
Ok(Key::Char('q')) | Ok(Key::Char('Q')) => return Err(io::Error::from(io::ErrorKind::Interrupted)),
_ => (),
}
};

View File

@@ -136,5 +136,9 @@ pub fn require<T: AsRef<OsStr> + Debug>(binary_name: T) -> Result<PathBuf> {
#[allow(dead_code)]
pub fn require_option<T>(option: Option<T>, cause: String) -> Result<T> {
option.ok_or_else(|| SkipStep(cause).into())
if let Some(value) = option {
Ok(value)
} else {
Err(SkipStep(cause).into())
}
}