diff --git a/src/config.rs b/src/config.rs index a8da781a..2acc8f4e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,5 @@ use super::error::{Error, ErrorKind}; +use super::executor::RunType; use directories::BaseDirs; use failure::ResultExt; use serde::Deserialize; @@ -78,7 +79,7 @@ pub struct Opt { /// Print what would be done #[structopt(short = "n", long = "dry-run")] - pub dry_run: bool, + pub run_type: RunType, /// Do not ask to retry failed steps #[structopt(long = "no-retry")] diff --git a/src/executor.rs b/src/executor.rs index 1e0f10c7..7e958f75 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -1,27 +1,71 @@ +//! Utilities for command execution use super::error::{Error, ErrorKind}; use super::utils::Check; use failure::ResultExt; use std::ffi::{OsStr, OsString}; use std::path::Path; use std::process::{Child, Command, ExitStatus}; +use std::str::{FromStr, ParseBoolError}; +/// An enum telling whether Topgrade should perform dry runs or actually perform the steps. +#[derive(Clone, Copy, Debug)] +pub enum RunType { + /// Executing commands will just print the command with its argument. + Dry, + + /// Executing commands will perform actual execution. + Wet, +} + +impl RunType { + /// Create a new instance from a boolean telling whether to dry run. + fn new(dry_run: bool) -> Self { + if dry_run { + RunType::Dry + } else { + RunType::Wet + } + } + + /// Create an instance of `Executor` that should run `program`. + pub fn execute>(self, program: S) -> Executor { + match self { + RunType::Dry => Executor::Dry(DryCommand { + program: program.as_ref().into(), + ..Default::default() + }), + RunType::Wet => Executor::Wet(Command::new(program)), + } + } + + #[cfg(feature = "self-update")] + /// Tells whether we're performing a dry run. + pub fn dry(self) -> bool { + match self { + RunType::Dry => true, + RunType::Wet => false, + } + } +} + +impl FromStr for RunType { + type Err = ParseBoolError; + + fn from_str(s: &str) -> Result { + Ok(Self::new(bool::from_str(s)?)) + } +} + +/// An enum providing a similar interface to `std::process::Command`. +/// If the enum is set to `Wet`, execution will be performed with `std::process::Command`. +/// If the enum is set to `Dry`, execution will just print the command with its arguments. pub enum Executor { Wet(Command), Dry(DryCommand), } impl Executor { - pub fn new>(program: S, dry: bool) -> Self { - if dry { - Executor::Dry(DryCommand { - program: program.as_ref().into(), - ..Default::default() - }) - } else { - Executor::Wet(Command::new(program)) - } - } - + /// See `std::process::Command::arg` pub fn arg>(&mut self, arg: S) -> &mut Executor { match self { Executor::Wet(c) => { @@ -35,6 +79,7 @@ impl Executor { self } + /// See `std::process::Command::args` pub fn args(&mut self, args: I) -> &mut Executor where I: IntoIterator, @@ -52,6 +97,7 @@ impl Executor { self } + /// See `std::process::Command::current_dir` pub fn current_dir>(&mut self, dir: P) -> &mut Executor { match self { Executor::Wet(c) => { @@ -63,6 +109,7 @@ impl Executor { self } + /// See `std::process::Command::spawn` pub fn spawn(&mut self) -> Result { let result = match self { Executor::Wet(c) => c.spawn().context(ErrorKind::ProcessExecution).map(ExecutorChild::Wet)?, @@ -88,6 +135,7 @@ impl Executor { } } +/// A struct represending a command. Trying to execute it will just print its arguments. #[derive(Default)] pub struct DryCommand { program: OsString, @@ -95,12 +143,14 @@ pub struct DryCommand { directory: Option, } +/// The Result of spawn. Contains an actual `std::process::Child` if executed by a wet command. pub enum ExecutorChild { Wet(Child), Dry, } impl ExecutorChild { + /// See `std::process::Child::wait` pub fn wait(&mut self) -> Result { let result = match self { ExecutorChild::Wet(c) => c @@ -114,6 +164,7 @@ impl ExecutorChild { } } +/// The Result of wait. Contains an actual `std::process::ExitStatus` if executed by a wet command. pub enum ExecutorExitStatus { Wet(ExitStatus), Dry, diff --git a/src/main.rs b/src/main.rs index 4c30014b..92b7098b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,7 +73,7 @@ fn run() -> Result<(), Error> { #[cfg(feature = "self-update")] { - if !opt.dry_run && env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() { + if !opt.run_type.dry() && env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() { if let Err(e) = self_update::self_update() { print_warning(format!("Self update error: {}", e)); if let Some(cause) = e.cause() { @@ -85,7 +85,7 @@ fn run() -> Result<(), Error> { if let Some(commands) = config.pre_commands() { for (name, command) in commands { - generic::run_custom_command(&name, &command, opt.dry_run).context(ErrorKind::PreCommand)?; + generic::run_custom_command(&name, &command, opt.run_type).context(ErrorKind::PreCommand)?; } } @@ -93,7 +93,7 @@ fn run() -> Result<(), Error> { let powershell = windows::Powershell::new(); #[cfg(windows)] - report.push_result(execute(|| powershell.update_modules(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| powershell.update_modules(opt.run_type), opt.no_retry)?); #[cfg(target_os = "linux")] let distribution = linux::Distribution::detect(); @@ -104,7 +104,7 @@ fn run() -> Result<(), Error> { match &distribution { Ok(distribution) => { report.push_result(execute( - || distribution.upgrade(&sudo, opt.cleanup, opt.dry_run), + || distribution.upgrade(&sudo, opt.cleanup, opt.run_type), opt.no_retry, )?); } @@ -112,22 +112,22 @@ fn run() -> Result<(), Error> { println!("Error detecting current distribution: {}", e); } } - report.push_result(execute(|| linux::run_etc_update(&sudo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| linux::run_etc_update(&sudo, opt.run_type), opt.no_retry)?); } } #[cfg(windows)] - report.push_result(execute(|| windows::run_chocolatey(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| windows::run_chocolatey(opt.run_type), opt.no_retry)?); #[cfg(windows)] - report.push_result(execute(|| windows::run_scoop(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| windows::run_scoop(opt.run_type), opt.no_retry)?); #[cfg(unix)] - report.push_result(execute(|| unix::run_homebrew(opt.cleanup, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| unix::run_homebrew(opt.cleanup, opt.run_type), opt.no_retry)?); #[cfg(target_os = "freebsd")] - report.push_result(execute(|| freebsd::upgrade_packages(&sudo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| freebsd::upgrade_packages(&sudo, opt.run_type), opt.no_retry)?); #[cfg(unix)] - report.push_result(execute(|| unix::run_nix(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| unix::run_nix(opt.run_type), opt.no_retry)?); if !opt.no_emacs { git_repos.insert(base_dirs.home_dir().join(".emacs.d")); @@ -162,42 +162,42 @@ fn run() -> Result<(), Error> { } } for repo in git_repos.repositories() { - report.push_result(execute(|| git.pull(&repo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| git.pull(&repo, opt.run_type), opt.no_retry)?); } #[cfg(unix)] { - report.push_result(execute(|| unix::run_zplug(&base_dirs, opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| unix::run_fisher(&base_dirs, opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| tmux::run_tpm(&base_dirs, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| unix::run_zplug(&base_dirs, opt.run_type), opt.no_retry)?); + report.push_result(execute(|| unix::run_fisher(&base_dirs, opt.run_type), opt.no_retry)?); + report.push_result(execute(|| tmux::run_tpm(&base_dirs, opt.run_type), opt.no_retry)?); } - report.push_result(execute(|| generic::run_rustup(&base_dirs, opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| generic::run_cargo_update(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| generic::run_rustup(&base_dirs, opt.run_type), opt.no_retry)?); + report.push_result(execute(|| generic::run_cargo_update(opt.run_type), opt.no_retry)?); if !opt.no_emacs { - report.push_result(execute(|| generic::run_emacs(&base_dirs, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| generic::run_emacs(&base_dirs, opt.run_type), opt.no_retry)?); } - report.push_result(execute(|| generic::run_opam_update(opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| generic::run_vcpkg_update(opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| generic::run_pipx_update(opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| generic::run_jetpack(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| generic::run_opam_update(opt.run_type), opt.no_retry)?); + report.push_result(execute(|| generic::run_vcpkg_update(opt.run_type), opt.no_retry)?); + report.push_result(execute(|| generic::run_pipx_update(opt.run_type), opt.no_retry)?); + report.push_result(execute(|| generic::run_jetpack(opt.run_type), opt.no_retry)?); if !opt.no_vim { - report.push_result(execute(|| vim::upgrade_vim(&base_dirs, opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| vim::upgrade_neovim(&base_dirs, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| vim::upgrade_vim(&base_dirs, opt.run_type), opt.no_retry)?); + report.push_result(execute(|| vim::upgrade_neovim(&base_dirs, opt.run_type), opt.no_retry)?); } report.push_result(execute( - || node::run_npm_upgrade(&base_dirs, opt.dry_run), + || node::run_npm_upgrade(&base_dirs, opt.run_type), opt.no_retry, )?); report.push_result(execute( - || generic::run_composer_update(&base_dirs, opt.dry_run), + || generic::run_composer_update(&base_dirs, opt.run_type), opt.no_retry, )?); - report.push_result(execute(|| node::yarn_global_update(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| node::yarn_global_update(opt.run_type), opt.no_retry)?); #[cfg(not(any( target_os = "freebsd", @@ -205,23 +205,23 @@ fn run() -> Result<(), Error> { target_os = "netbsd", target_os = "dragonfly" )))] - report.push_result(execute(|| generic::run_apm(opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| generic::run_gem(&base_dirs, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| generic::run_apm(opt.run_type), opt.no_retry)?); + report.push_result(execute(|| generic::run_gem(&base_dirs, opt.run_type), opt.no_retry)?); #[cfg(target_os = "linux")] { - report.push_result(execute(|| linux::flatpak_user_update(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| linux::flatpak_user_update(opt.run_type), opt.no_retry)?); report.push_result(execute( - || linux::flatpak_global_update(&sudo, opt.dry_run), + || linux::flatpak_global_update(&sudo, opt.run_type), opt.no_retry, )?); - report.push_result(execute(|| linux::run_snap(&sudo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| linux::run_snap(&sudo, opt.run_type), opt.no_retry)?); } if let Some(commands) = config.commands() { for (name, command) in commands { report.push_result(execute( - || Some((name, generic::run_custom_command(&name, &command, opt.dry_run).is_ok())), + || Some((name, generic::run_custom_command(&name, &command, opt.run_type).is_ok())), opt.no_retry, )?); } @@ -229,28 +229,28 @@ fn run() -> Result<(), Error> { #[cfg(target_os = "linux")] { - report.push_result(execute(|| linux::run_fwupdmgr(opt.dry_run), opt.no_retry)?); - report.push_result(execute(|| linux::run_needrestart(&sudo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| linux::run_fwupdmgr(opt.run_type), opt.no_retry)?); + report.push_result(execute(|| linux::run_needrestart(&sudo, opt.run_type), opt.no_retry)?); } #[cfg(target_os = "macos")] { if !opt.no_system { - report.push_result(execute(|| macos::upgrade_macos(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| macos::upgrade_macos(opt.run_type), opt.no_retry)?); } } #[cfg(target_os = "freebsd")] { if !opt.no_system { - report.push_result(execute(|| freebsd::upgrade_freebsd(&sudo, opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| freebsd::upgrade_freebsd(&sudo, opt.run_type), opt.no_retry)?); } } #[cfg(windows)] { if !opt.no_system { - report.push_result(execute(|| powershell.windows_update(opt.dry_run), opt.no_retry)?); + report.push_result(execute(|| powershell.windows_update(opt.run_type), opt.no_retry)?); } } diff --git a/src/steps/generic.rs b/src/steps/generic.rs index a716c9f6..2aef7da6 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -1,5 +1,5 @@ use crate::error::{Error, ErrorKind}; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::print_separator; use crate::utils::{self, Check, PathExt}; use directories::BaseDirs; @@ -10,12 +10,13 @@ use std::process::Command; const EMACS_UPGRADE: &str = include_str!("emacs.el"); #[must_use] -pub fn run_cargo_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_cargo_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(cargo_update) = utils::which("cargo-install-update") { print_separator("Cargo"); let success = || -> Result<(), Error> { - Executor::new(cargo_update, dry_run) + run_type + .execute(cargo_update) .args(&["install-update", "--git", "--all"]) .spawn()? .wait()? @@ -32,13 +33,14 @@ pub fn run_cargo_update(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_gem(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_gem(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(gem) = utils::which("gem") { if base_dirs.home_dir().join(".gem").exists() { print_separator("RubyGems"); let success = || -> Result<(), Error> { - Executor::new(&gem, dry_run) + run_type + .execute(&gem) .args(&["update", "--user-install"]) .spawn()? .wait()? @@ -55,13 +57,14 @@ pub fn run_gem(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, boo } #[must_use] -pub fn run_emacs(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_emacs(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(emacs) = utils::which("emacs") { if let Some(init_file) = base_dirs.home_dir().join(".emacs.d/init.el").if_exists() { print_separator("Emacs"); let success = || -> Result<(), Error> { - Executor::new(&emacs, dry_run) + run_type + .execute(&emacs) .args(&["--batch", "-l", init_file.to_str().unwrap(), "--eval", EMACS_UPGRADE]) .spawn()? .wait()? @@ -84,12 +87,13 @@ pub fn run_emacs(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, b target_os = "netbsd", target_os = "dragonfly" )))] -pub fn run_apm(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_apm(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(apm) = utils::which("apm") { print_separator("Atom Package Manager"); let success = || -> Result<(), Error> { - Executor::new(&apm, dry_run) + run_type + .execute(&apm) .args(&["upgrade", "--confirm=false"]) .spawn()? .wait()? @@ -106,20 +110,21 @@ pub fn run_apm(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_rustup(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_rustup(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(rustup) = utils::which("rustup") { print_separator("rustup"); let success = || -> Result<(), Error> { if rustup.is_descendant_of(base_dirs.home_dir()) { - Executor::new(&rustup, dry_run) + run_type + .execute(&rustup) .args(&["self", "update"]) .spawn()? .wait()? .check()?; } - Executor::new(&rustup, dry_run).arg("update").spawn()?.wait()?.check()?; + run_type.execute(&rustup).arg("update").spawn()?.wait()?; Ok(()) }() .is_ok(); @@ -131,12 +136,13 @@ pub fn run_rustup(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, } #[must_use] -pub fn run_jetpack(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_jetpack(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(jetpack) = utils::which("jetpack") { print_separator("Jetpack"); let success = || -> Result<(), Error> { - Executor::new(&jetpack, dry_run) + run_type + .execute(&jetpack) .args(&["global", "update"]) .spawn()? .wait()? @@ -152,13 +158,13 @@ pub fn run_jetpack(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_opam_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_opam_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(opam) = utils::which("opam") { print_separator("OCaml Package Manager"); let success = || -> Result<(), Error> { - Executor::new(&opam, dry_run).arg("update").spawn()?.wait()?.check()?; - Executor::new(&opam, dry_run).arg("upgrade").spawn()?.wait()?.check()?; + run_type.execute(&opam).arg("update").spawn()?.wait()?; + run_type.execute(&opam).arg("upgrade").spawn()?.wait()?; Ok(()) }() .is_ok(); @@ -170,12 +176,13 @@ pub fn run_opam_update(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_vcpkg_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_vcpkg_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(vcpkg) = utils::which("vcpkg") { print_separator("vcpkg"); let success = || -> Result<(), Error> { - Executor::new(&vcpkg, dry_run) + run_type + .execute(&vcpkg) .args(&["upgrade", "--no-dry-run"]) .spawn()? .wait()? @@ -191,16 +198,12 @@ pub fn run_vcpkg_update(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_pipx_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_pipx_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(pipx) = utils::which("pipx") { print_separator("pipx"); let success = || -> Result<(), Error> { - Executor::new(&pipx, dry_run) - .arg("upgrade-all") - .spawn()? - .wait()? - .check()?; + run_type.execute(&pipx).arg("upgrade-all").spawn()?.wait()?.check()?; Ok(()) }() .is_ok(); @@ -212,20 +215,15 @@ pub fn run_pipx_update(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_custom_command(name: &str, command: &str, dry_run: bool) -> Result<(), Error> { +pub fn run_custom_command(name: &str, command: &str, run_type: RunType) -> Result<(), Error> { print_separator(name); - Executor::new("sh", dry_run) - .arg("-c") - .arg(command) - .spawn()? - .wait()? - .check()?; + run_type.execute("sh").arg("-c").arg(command).spawn()?.wait()?.check()?; Ok(()) } #[must_use] -pub fn run_composer_update(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(composer) = utils::which("composer") { let composer_home = || -> Result { let output = Command::new(&composer) @@ -243,14 +241,15 @@ pub fn run_composer_update(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'sta print_separator("Composer"); let success = || -> Result<(), Error> { - Executor::new(&composer, dry_run) + run_type + .execute(&composer) .args(&["global", "update"]) .spawn()? .wait()? .check()?; if let Some(valet) = utils::which("valet") { - Executor::new(&valet, dry_run).arg("install").spawn()?.wait()?.check()?; + run_type.execute(&valet).arg("install").spawn()?.wait()?; } Ok(()) diff --git a/src/steps/git.rs b/src/steps/git.rs index e0a5e3f1..6dcb055a 100644 --- a/src/steps/git.rs +++ b/src/steps/git.rs @@ -1,5 +1,5 @@ use crate::error::Error; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::print_separator; use crate::utils::{which, Check}; use log::{debug, error}; @@ -58,7 +58,7 @@ impl Git { None } - pub fn pull>(&self, path: P, dry_run: bool) -> Option<(String, bool)> { + pub fn pull>(&self, path: P, run_type: RunType) -> Option<(String, bool)> { let path = path.as_ref(); print_separator(format!("Pulling {}", path.display())); @@ -66,14 +66,16 @@ impl Git { let git = self.git.as_ref().unwrap(); let success = || -> Result<(), Error> { - Executor::new(git, dry_run) + run_type + .execute(git) .args(&["pull", "--rebase", "--autostash"]) .current_dir(&path) .spawn()? .wait()? .check()?; - Executor::new(git, dry_run) + run_type + .execute(git) .args(&["submodule", "update", "--init", "--recursive"]) .current_dir(&path) .spawn()? diff --git a/src/steps/node.rs b/src/steps/node.rs index f0114415..1d5edc27 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -1,5 +1,5 @@ use crate::error::{Error, ErrorKind}; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::print_separator; use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; @@ -29,8 +29,9 @@ impl NPM { )) } - fn upgrade(&self, dry_run: bool) -> Result<(), Error> { - Executor::new(&self.command, dry_run) + fn upgrade(&self, run_type: RunType) -> Result<(), Error> { + run_type + .execute(&self.command) .args(&["update", "-g"]) .spawn()? .wait()? @@ -41,12 +42,12 @@ impl NPM { } #[must_use] -pub fn run_npm_upgrade(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_npm_upgrade(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(npm) = which("npm").map(NPM::new) { if let Ok(npm_root) = npm.root() { if npm_root.is_descendant_of(base_dirs.home_dir()) { print_separator("Node Package Manager"); - let success = npm.upgrade(dry_run).is_ok(); + let success = npm.upgrade(run_type).is_ok(); return Some(("NPM", success)); } } @@ -55,12 +56,13 @@ pub fn run_npm_upgrade(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static } #[must_use] -pub fn yarn_global_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn yarn_global_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(yarn) = which("yarn") { print_separator("Yarn"); let success = || -> Result<(), Error> { - Executor::new(&yarn, dry_run) + run_type + .execute(&yarn) .args(&["global", "upgrade", "-s"]) .spawn()? .wait()? diff --git a/src/steps/os/freebsd.rs b/src/steps/os/freebsd.rs index 30c0a72c..6579373d 100644 --- a/src/steps/os/freebsd.rs +++ b/src/steps/os/freebsd.rs @@ -7,12 +7,12 @@ use std::path::PathBuf; use std::process::Command; #[must_use] -pub fn upgrade_freebsd(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn upgrade_freebsd(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { print_separator("FreeBSD Update"); if let Some(sudo) = sudo { let success = || -> Result<(), Error> { - Executor::new(sudo, dry_run) + run_type.execute(sudo) .args(&["/usr/sbin/freebsd-update", "fetch", "install"]) .spawn()? .wait()? @@ -29,12 +29,12 @@ pub fn upgrade_freebsd(sudo: &Option, dry_run: bool) -> Option<(&'stati } #[must_use] -pub fn upgrade_packages(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn upgrade_packages(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { print_separator("FreeBSD Packages"); if let Some(sudo) = sudo { let success = || -> Result<(), Error> { - Executor::new(sudo, dry_run) + run_type.execute(sudo) .args(&["/usr/sbin/pkg", "upgrade"]) .spawn()? .wait()? diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 15f6a386..36c39a3e 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -1,5 +1,5 @@ use crate::error::{Error, ErrorKind}; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::{print_separator, print_warning}; use crate::utils::{which, Check}; use failure::ResultExt; @@ -59,17 +59,17 @@ impl Distribution { } #[must_use] - pub fn upgrade(self, sudo: &Option, cleanup: bool, dry_run: bool) -> Option<(&'static str, bool)> { + pub fn upgrade(self, sudo: &Option, cleanup: bool, run_type: RunType) -> Option<(&'static str, bool)> { print_separator("System update"); let success = match self { - Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, dry_run), - Distribution::CentOS => upgrade_redhat(&sudo, dry_run), - Distribution::Fedora => upgrade_fedora(&sudo, dry_run), - Distribution::Ubuntu | Distribution::Debian => upgrade_debian(&sudo, cleanup, dry_run), - Distribution::Gentoo => upgrade_gentoo(&sudo, dry_run), - Distribution::OpenSuse => upgrade_opensuse(&sudo, dry_run), - Distribution::Void => upgrade_void(&sudo, dry_run), + Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type), + Distribution::CentOS => upgrade_redhat(&sudo, run_type), + Distribution::Fedora => upgrade_fedora(&sudo, run_type), + Distribution::Ubuntu | Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type), + Distribution::Gentoo => upgrade_gentoo(&sudo, run_type), + Distribution::OpenSuse => upgrade_opensuse(&sudo, run_type), + Distribution::Void => upgrade_void(&sudo, run_type), }; Some(("System update", success.is_ok())) @@ -103,7 +103,7 @@ pub fn show_pacnew() { } } -fn upgrade_arch_linux(sudo: &Option, cleanup: bool, dry_run: bool) -> Result<(), Error> { +fn upgrade_arch_linux(sudo: &Option, cleanup: bool, run_type: RunType) -> Result<(), Error> { if let Some(yay) = which("yay") { if let Some(python) = which("python") { if python != PathBuf::from("/usr/bin/python") { @@ -115,10 +115,10 @@ It's dangerous to run yay since Python based AUR packages will be installed in t return Err(ErrorKind::NotSystemPython)?; } } - - Executor::new(yay, dry_run).spawn()?.wait()?.check()?; + run_type.execute(yay).spawn()?.wait()?.check()?; } else if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/pacman", "-Syu"]) .spawn()? .wait()? @@ -129,7 +129,8 @@ It's dangerous to run yay since Python based AUR packages will be installed in t if cleanup { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/pacman", "-Scc"]) .spawn()? .wait()? @@ -140,9 +141,10 @@ It's dangerous to run yay since Python based AUR packages will be installed in t Ok(()) } -fn upgrade_redhat(sudo: &Option, dry_run: bool) -> Result<(), Error> { +fn upgrade_redhat(sudo: &Option, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/yum", "upgrade"]) .spawn()? .wait()? @@ -154,15 +156,17 @@ fn upgrade_redhat(sudo: &Option, dry_run: bool) -> Result<(), Error> { Ok(()) } -fn upgrade_opensuse(sudo: &Option, dry_run: bool) -> Result<(), Error> { +fn upgrade_opensuse(sudo: &Option, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/zypper", "refresh"]) .spawn()? .wait()? .check()?; - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/zypper", "dist-upgrade"]) .spawn()? .wait()? @@ -174,9 +178,10 @@ fn upgrade_opensuse(sudo: &Option, dry_run: bool) -> Result<(), Error> Ok(()) } -fn upgrade_void(sudo: &Option, dry_run: bool) -> Result<(), Error> { +fn upgrade_void(sudo: &Option, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/xbps-install", "-Su"]) .spawn()? .wait()? @@ -188,9 +193,10 @@ fn upgrade_void(sudo: &Option, dry_run: bool) -> Result<(), Error> { Ok(()) } -fn upgrade_fedora(sudo: &Option, dry_run: bool) -> Result<(), Error> { +fn upgrade_fedora(sudo: &Option, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/dnf", "upgrade"]) .spawn()? .wait()? @@ -202,10 +208,11 @@ fn upgrade_fedora(sudo: &Option, dry_run: bool) -> Result<(), Error> { Ok(()) } -fn upgrade_gentoo(sudo: &Option, dry_run: bool) -> Result<(), Error> { +fn upgrade_gentoo(sudo: &Option, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { if let Some(layman) = which("layman") { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .arg(layman) .args(&["-s", "ALL"]) .spawn()? @@ -214,7 +221,8 @@ fn upgrade_gentoo(sudo: &Option, dry_run: bool) -> Result<(), Error> { } println!("Syncing portage"); - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .arg("/usr/bin/emerge") .args(&["-q", "--sync"]) .spawn()? @@ -222,10 +230,11 @@ fn upgrade_gentoo(sudo: &Option, dry_run: bool) -> Result<(), Error> { .check()?; if let Some(eix_update) = which("eix-update") { - Executor::new(&sudo, dry_run).arg(eix_update).spawn()?.wait()?.check()?; + run_type.execute(&sudo).arg(eix_update).spawn()?.wait()?; } - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .arg("/usr/bin/emerge") .args(&["-uDNa", "world"]) .spawn()? @@ -238,28 +247,32 @@ fn upgrade_gentoo(sudo: &Option, dry_run: bool) -> Result<(), Error> { Ok(()) } -fn upgrade_debian(sudo: &Option, cleanup: bool, dry_run: bool) -> Result<(), Error> { +fn upgrade_debian(sudo: &Option, cleanup: bool, run_type: RunType) -> Result<(), Error> { if let Some(sudo) = &sudo { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/apt", "update"]) .spawn()? .wait()? .check()?; - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/apt", "dist-upgrade"]) .spawn()? .wait()? .check()?; if cleanup { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/apt", "clean"]) .spawn()? .wait()? .check()?; - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&["/usr/bin/apt", "autoremove"]) .spawn()? .wait()? @@ -273,17 +286,13 @@ fn upgrade_debian(sudo: &Option, cleanup: bool, dry_run: bool) -> Resul } #[must_use] -pub fn run_needrestart(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_needrestart(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(sudo) = sudo { if let Some(needrestart) = which("needrestart") { print_separator("Check for needed restarts"); let success = || -> Result<(), Error> { - Executor::new(&sudo, dry_run) - .arg(needrestart) - .spawn()? - .wait()? - .check()?; + run_type.execute(&sudo).arg(needrestart).spawn()?.wait()?.check()?; Ok(()) }() @@ -297,17 +306,14 @@ pub fn run_needrestart(sudo: &Option, dry_run: bool) -> Option<(&'stati } #[must_use] -pub fn run_fwupdmgr(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_fwupdmgr(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(fwupdmgr) = which("fwupdmgr") { print_separator("Firmware upgrades"); let success = || -> Result<(), Error> { - Executor::new(&fwupdmgr, dry_run) - .arg("refresh") - .spawn()? - .wait()? - .check()?; - Executor::new(&fwupdmgr, dry_run) + run_type.execute(&fwupdmgr).arg("refresh").spawn()?.wait()?.check()?; + run_type + .execute(&fwupdmgr) .arg("get-updates") .spawn()? .wait()? @@ -323,12 +329,13 @@ pub fn run_fwupdmgr(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn flatpak_user_update(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn flatpak_user_update(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(flatpak) = which("flatpak") { print_separator("Flatpak User Packages"); let success = || -> Result<(), Error> { - Executor::new(&flatpak, dry_run) + run_type + .execute(&flatpak) .args(&["update", "--user", "-y"]) .spawn()? .wait()? @@ -344,13 +351,14 @@ pub fn flatpak_user_update(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn flatpak_global_update(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn flatpak_global_update(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(sudo) = sudo { if let Some(flatpak) = which("flatpak") { print_separator("Flatpak Global Packages"); let success = || -> Result<(), Error> { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&[flatpak.to_str().unwrap(), "update", "-y"]) .spawn()? .wait()? @@ -367,14 +375,15 @@ pub fn flatpak_global_update(sudo: &Option, dry_run: bool) -> Option<(& } #[must_use] -pub fn run_snap(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_snap(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(sudo) = sudo { if let Some(snap) = which("snap") { if PathBuf::from("/var/snapd.socket").exists() { print_separator("snap"); let success = || -> Result<(), Error> { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .args(&[snap.to_str().unwrap(), "refresh"]) .spawn()? .wait()? @@ -393,13 +402,14 @@ pub fn run_snap(sudo: &Option, dry_run: bool) -> Option<(&'static str, } #[must_use] -pub fn run_etc_update(sudo: &Option, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_etc_update(sudo: &Option, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(sudo) = sudo { if let Some(etc_update) = which("etc-update") { print_separator("etc-update"); let success = || -> Result<(), Error> { - Executor::new(&sudo, dry_run) + run_type + .execute(&sudo) .arg(&etc_update.to_str().unwrap()) .spawn()? .wait()? diff --git a/src/steps/os/macos.rs b/src/steps/os/macos.rs index 184247b3..49d5a331 100644 --- a/src/steps/os/macos.rs +++ b/src/steps/os/macos.rs @@ -4,11 +4,11 @@ use crate::terminal::print_separator; use crate::utils::Check; #[must_use] -pub fn upgrade_macos(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn upgrade_macos(run_type: RunType) -> Option<(&'static str, bool)> { print_separator("App Store"); let success = || -> Result<(), Error> { - Executor::new("softwareupdate", dry_run) + run_type.execute("softwareupdate") .args(&["--install", "--all"]) .spawn()? .wait()? diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 57c23443..b0e80f30 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -1,16 +1,17 @@ use crate::error::Error; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::print_separator; use crate::utils::{which, Check}; use directories::BaseDirs; -pub fn run_zplug(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_zplug(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(zsh) = which("zsh") { if base_dirs.home_dir().join(".zplug").exists() { print_separator("zplug"); let success = || -> Result<(), Error> { - Executor::new(zsh, dry_run) + run_type + .execute(zsh) .args(&["-c", "source ~/.zshrc && zplug update"]) .spawn()? .wait()? @@ -26,18 +27,20 @@ pub fn run_zplug(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, b None } -pub fn run_fisher(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(fish) = which("fish") { if base_dirs.home_dir().join(".config/fish/functions/fisher.fish").exists() { print_separator("fisher"); let success = || -> Result<(), Error> { - Executor::new(&fish, dry_run) + run_type + .execute(&fish) .args(&["-c", "fisher self-update"]) .spawn()? .wait()? .check()?; - Executor::new(&fish, dry_run) + run_type + .execute(&fish) .args(&["-c", "fisher"]) .spawn()? .wait()? @@ -54,20 +57,21 @@ pub fn run_fisher(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, } #[must_use] -pub fn run_homebrew(cleanup: bool, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_homebrew(cleanup: bool, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(brew) = which("brew") { print_separator("Brew"); let inner = || -> Result<(), Error> { - Executor::new(&brew, dry_run).arg("update").spawn()?.wait()?.check()?; - Executor::new(&brew, dry_run).arg("upgrade").spawn()?.wait()?.check()?; - Executor::new(&brew, dry_run) + run_type.execute(&brew).arg("update").spawn()?.wait()?; + run_type.execute(&brew).arg("upgrade").spawn()?.wait()?; + run_type + .execute(&brew) .args(&["cask", "upgrade"]) .spawn()? .wait()? .check()?; if cleanup { - Executor::new(&brew, dry_run).arg("cleanup").spawn()?.wait()?.check()?; + run_type.execute(&brew).arg("cleanup").spawn()?.wait()?; } Ok(()) }; @@ -79,22 +83,14 @@ pub fn run_homebrew(cleanup: bool, dry_run: bool) -> Option<(&'static str, bool) } #[must_use] -pub fn run_nix(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_nix(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(nix) = which("nix") { if let Some(nix_env) = which("nix-env") { print_separator("Nix"); let inner = || -> Result<(), Error> { - Executor::new(&nix, dry_run) - .arg("upgrade-nix") - .spawn()? - .wait()? - .check()?; - Executor::new(&nix_env, dry_run) - .arg("--upgrade") - .spawn()? - .wait()? - .check()?; + run_type.execute(&nix).arg("upgrade-nix").spawn()?.wait()?.check()?; + run_type.execute(&nix_env).arg("--upgrade").spawn()?.wait()?.check()?; Ok(()) }; diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index b40ac55d..44baad01 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -8,12 +8,12 @@ use std::path::PathBuf; use std::process::Command; #[must_use] -pub fn run_chocolatey(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_chocolatey(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(choco) = utils::which("choco") { print_separator("Chocolatey"); let success = || -> Result<(), Error> { - Executor::new(&choco, dry_run) + run_type.execute(&choco) .args(&["upgrade", "all"]) .spawn()? .wait()? @@ -29,17 +29,17 @@ pub fn run_chocolatey(dry_run: bool) -> Option<(&'static str, bool)> { } #[must_use] -pub fn run_scoop(dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_scoop(run_type: RunType) -> Option<(&'static str, bool)> { if let Some(scoop) = utils::which("scoop") { print_separator("Scoop"); let success = || -> Result<(), Error> { - Executor::new(&scoop, dry_run) + run_type.execute(&scoop) .args(&["update"]) .spawn()? .wait()? .check()?; - Executor::new(&scoop, dry_run) + run_type.execute(&scoop) .args(&["update", "*"]) .spawn()? .wait()? @@ -99,12 +99,12 @@ impl Powershell { } #[must_use] - pub fn update_modules(&self, dry_run: bool) -> Option<(&'static str, bool)> { + pub fn update_modules(&self, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(powershell) = &self.path { print_separator("Powershell Modules Update"); let success = || -> Result<(), Error> { - Executor::new(&powershell, dry_run) + run_type.execute(&powershell) .arg("Update-Module") .spawn()? .wait()? @@ -120,13 +120,13 @@ impl Powershell { } #[must_use] - pub fn windows_update(&self, dry_run: bool) -> Option<(&'static str, bool)> { + pub fn windows_update(&self, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(powershell) = &self.path { if Self::has_command(&powershell, "Install-WindowsUpdate") { print_separator("Windows Update"); let success = || -> Result<(), Error> { - Executor::new(&powershell, dry_run) + run_type.execute(&powershell) .args(&["-Command", "Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose"]) .spawn()? .wait()? diff --git a/src/steps/tmux.rs b/src/steps/tmux.rs index 41e64dfa..93c2f0ab 100644 --- a/src/steps/tmux.rs +++ b/src/steps/tmux.rs @@ -1,5 +1,5 @@ use crate::error::{Error, ErrorKind}; -use crate::executor::Executor; +use crate::executor::RunType; use crate::terminal::print_separator; use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; @@ -10,7 +10,7 @@ use std::os::unix::process::CommandExt; use std::path::Path; use std::process::Command; -pub fn run_tpm(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn run_tpm(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(tpm) = base_dirs .home_dir() .join(".tmux/plugins/tpm/bin/update_plugins") @@ -19,7 +19,7 @@ pub fn run_tpm(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, boo print_separator("tmux plugins"); let success = || -> Result<(), Error> { - Executor::new(&tpm, dry_run).arg("all").spawn()?.wait()?.check()?; + run_type.execute(&tpm).arg("all").spawn()?.wait()?; Ok(()) }() .is_ok(); diff --git a/src/steps/vim.rs b/src/steps/vim.rs index fcbb4699..f16549ad 100644 --- a/src/steps/vim.rs +++ b/src/steps/vim.rs @@ -1,5 +1,5 @@ use crate::error::Error; -use crate::executor::Executor; +use crate::executor::{RunType}; use crate::terminal::print_separator; use crate::utils::{which, Check, PathExt}; use directories::BaseDirs; @@ -54,8 +54,8 @@ fn nvimrc(base_dirs: &BaseDirs) -> Option { } #[must_use] -fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, dry_run: bool) -> Result<(), Error> { - Executor::new(&vim, dry_run) +fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, run_type: RunType) -> Result<(), Error> { + run_type.execute(&vim) .args(&[ "-N", "-u", @@ -78,12 +78,12 @@ fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, dr } #[must_use] -pub fn upgrade_vim(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn upgrade_vim(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(vim) = which("vim") { if let Some(vimrc) = vimrc(&base_dirs) { if let Some(plugin_framework) = PluginFramework::detect(&vimrc) { print_separator(&format!("Vim ({:?})", plugin_framework)); - let success = upgrade(&vim, &vimrc, plugin_framework, dry_run).is_ok(); + let success = upgrade(&vim, &vimrc, plugin_framework, run_type).is_ok(); return Some(("vim", success)); } } @@ -93,12 +93,12 @@ pub fn upgrade_vim(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, } #[must_use] -pub fn upgrade_neovim(base_dirs: &BaseDirs, dry_run: bool) -> Option<(&'static str, bool)> { +pub fn upgrade_neovim(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static str, bool)> { if let Some(nvim) = which("nvim") { if let Some(nvimrc) = nvimrc(&base_dirs) { if let Some(plugin_framework) = PluginFramework::detect(&nvimrc) { print_separator(&format!("Neovim ({:?})", plugin_framework)); - let success = upgrade(&nvim, &nvimrc, plugin_framework, dry_run).is_ok(); + let success = upgrade(&nvim, &nvimrc, plugin_framework, run_type).is_ok(); return Some(("Neovim", success)); } }