refactor: move RunType::execute to ExecutionContext
This commit is contained in:
@@ -47,8 +47,7 @@ To add a new `step` to `topgrade`:
|
||||
print_separator("xxx");
|
||||
|
||||
// Invoke the new step to get things updated!
|
||||
ctx.run_type()
|
||||
.execute(xxx)
|
||||
ctx.execute(xxx)
|
||||
.arg(/* args required by this step */)
|
||||
.status_checked()
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
use color_eyre::eyre::Result;
|
||||
use rust_i18n::t;
|
||||
use std::env::var;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
|
||||
use crate::executor::RunType;
|
||||
use crate::executor::DryCommand;
|
||||
use crate::powershell::Powershell;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::steps::linux::Distribution;
|
||||
@@ -13,6 +15,35 @@ use crate::sudo::Sudo;
|
||||
use crate::utils::{get_require_sudo_string, require_option};
|
||||
use crate::{config::Config, executor::Executor};
|
||||
|
||||
/// 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.
|
||||
pub fn new(dry_run: bool) -> Self {
|
||||
if dry_run {
|
||||
RunType::Dry
|
||||
} else {
|
||||
RunType::Wet
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells whether we're performing a dry run.
|
||||
pub fn dry(self) -> bool {
|
||||
match self {
|
||||
RunType::Dry => true,
|
||||
RunType::Wet => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExecutionContext<'a> {
|
||||
run_type: RunType,
|
||||
sudo: Option<Sudo>,
|
||||
@@ -48,6 +79,16 @@ impl<'a> ExecutionContext<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an instance of `Executor` that should run `program`.
|
||||
pub fn execute<S: AsRef<OsStr>>(&self, program: S) -> Executor {
|
||||
match self.run_type {
|
||||
RunType::Dry => Executor::Dry(DryCommand::new(program)),
|
||||
RunType::Wet => Executor::Wet(Command::new(program)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an instance of `Executor` that should run `program`,
|
||||
/// using sudo to elevate privileges.
|
||||
pub fn execute_elevated(&self, command: &Path, interactive: bool) -> Result<Executor> {
|
||||
let sudo = require_option(self.sudo.as_ref(), get_require_sudo_string())?;
|
||||
Ok(sudo.execute_elevated(self, command, interactive))
|
||||
|
||||
@@ -10,46 +10,6 @@ use tracing::debug;
|
||||
use crate::command::CommandExt;
|
||||
use crate::error::DryRun;
|
||||
|
||||
/// 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.
|
||||
pub 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<S: AsRef<OsStr>>(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)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells whether we're performing a dry run.
|
||||
pub fn dry(self) -> bool {
|
||||
match self {
|
||||
RunType::Dry => true,
|
||||
RunType::Wet => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@@ -207,8 +167,7 @@ pub enum ExecutorOutput {
|
||||
Dry,
|
||||
}
|
||||
|
||||
/// A struct represending a command. Trying to execute it will just print its arguments.
|
||||
#[derive(Default)]
|
||||
/// A struct representing a command. Trying to execute it will just print its arguments.
|
||||
pub struct DryCommand {
|
||||
program: OsString,
|
||||
args: Vec<OsString>,
|
||||
@@ -216,6 +175,14 @@ pub struct DryCommand {
|
||||
}
|
||||
|
||||
impl DryCommand {
|
||||
pub fn new<S: AsRef<OsStr>>(program: S) -> Self {
|
||||
Self {
|
||||
program: program.as_ref().to_os_string(),
|
||||
args: Vec::new(),
|
||||
directory: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn dry_run(&self) {
|
||||
print!(
|
||||
"{}",
|
||||
|
||||
@@ -139,7 +139,7 @@ fn run() -> Result<()> {
|
||||
let distribution = linux::Distribution::detect();
|
||||
|
||||
let sudo = config.sudo_command().map_or_else(sudo::Sudo::detect, sudo::Sudo::new);
|
||||
let run_type = executor::RunType::new(config.dry_run());
|
||||
let run_type = execution_context::RunType::new(config.dry_run());
|
||||
let ctx = execution_context::ExecutionContext::new(
|
||||
run_type,
|
||||
sudo,
|
||||
|
||||
@@ -148,7 +148,7 @@ pub fn run_containers(ctx: &ExecutionContext) -> Result<()> {
|
||||
"--platform",
|
||||
container.platform.as_str(),
|
||||
];
|
||||
let mut exec = ctx.run_type().execute(&crt);
|
||||
let mut exec = ctx.execute(&crt);
|
||||
|
||||
if let Err(e) = exec.args(&args).status_checked() {
|
||||
error!("Pulling container '{}' failed: {}", container, e);
|
||||
@@ -177,12 +177,7 @@ pub fn run_containers(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().cleanup() {
|
||||
// Remove dangling images
|
||||
debug!("Removing dangling images");
|
||||
if let Err(e) = ctx
|
||||
.run_type()
|
||||
.execute(&crt)
|
||||
.args(["image", "prune", "-f"])
|
||||
.status_checked()
|
||||
{
|
||||
if let Err(e) = ctx.execute(&crt).args(["image", "prune", "-f"]).status_checked() {
|
||||
error!("Removing dangling images failed: {}", e);
|
||||
success = false;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Emacs {
|
||||
fn update_doom(doom: &Path, ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Doom Emacs");
|
||||
|
||||
let mut command = ctx.run_type().execute(doom);
|
||||
let mut command = ctx.execute(doom);
|
||||
if ctx.config().yes(Step::Emacs) {
|
||||
command.arg("--force");
|
||||
}
|
||||
@@ -84,7 +84,7 @@ impl Emacs {
|
||||
|
||||
print_separator("Emacs");
|
||||
|
||||
let mut command = ctx.run_type().execute(emacs);
|
||||
let mut command = ctx.execute(emacs);
|
||||
|
||||
command
|
||||
.args(["--batch", "--debug-init", "-l"])
|
||||
|
||||
@@ -70,8 +70,7 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep(message).into());
|
||||
};
|
||||
|
||||
ctx.run_type()
|
||||
.execute(cargo_update)
|
||||
ctx.execute(cargo_update)
|
||||
.args(["install-update", "--git", "--all"])
|
||||
.status_checked()?;
|
||||
|
||||
@@ -80,7 +79,7 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
.ok()
|
||||
.or_else(|| cargo_dir.join("bin/cargo-cache").if_exists());
|
||||
if let Some(e) = cargo_cache {
|
||||
ctx.run_type().execute(e).args(["-a"]).status_checked()?;
|
||||
ctx.execute(e).args(["-a"]).status_checked()?;
|
||||
} else {
|
||||
let message = String::from("cargo-cache isn't installed so Topgrade can't cleanup cargo packages.\nInstall cargo-cache by running `cargo install cargo-cache`");
|
||||
print_warning(message);
|
||||
@@ -94,7 +93,7 @@ pub fn run_flutter_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
let flutter = require("flutter")?;
|
||||
|
||||
print_separator("Flutter");
|
||||
ctx.run_type().execute(flutter).arg("upgrade").status_checked()
|
||||
ctx.execute(flutter).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_gem(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -103,7 +102,7 @@ pub fn run_gem(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Gems");
|
||||
|
||||
let mut command = ctx.run_type().execute(gem);
|
||||
let mut command = ctx.execute(gem);
|
||||
command.arg("update");
|
||||
|
||||
if env::var_os("RBENV_SHELL").is_none() {
|
||||
@@ -125,15 +124,11 @@ pub fn run_rubygems(ctx: &ExecutionContext) -> Result<()> {
|
||||
|| gem_path_str.to_str().unwrap().contains(".rbenv")
|
||||
|| gem_path_str.to_str().unwrap().contains(".rvm")
|
||||
{
|
||||
ctx.run_type()
|
||||
.execute(gem)
|
||||
.args(["update", "--system"])
|
||||
.status_checked()?;
|
||||
ctx.execute(gem).args(["update", "--system"]).status_checked()?;
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
if !Path::new("/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb").exists() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg("-EH")
|
||||
.arg(gem)
|
||||
.args(["update", "--system"])
|
||||
@@ -157,10 +152,10 @@ pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("haxelib");
|
||||
|
||||
let mut command = if directory_writable {
|
||||
ctx.run_type().execute(&haxelib)
|
||||
ctx.execute(&haxelib)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&haxelib);
|
||||
c
|
||||
};
|
||||
@@ -173,10 +168,7 @@ pub fn run_sheldon(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Sheldon");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sheldon)
|
||||
.args(["lock", "--update"])
|
||||
.status_checked()
|
||||
ctx.execute(sheldon).args(["lock", "--update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_fossil(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -184,7 +176,7 @@ pub fn run_fossil(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Fossil");
|
||||
|
||||
ctx.run_type().execute(fossil).args(["all", "sync"]).status_checked()
|
||||
ctx.execute(fossil).args(["all", "sync"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -193,7 +185,6 @@ pub fn run_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("micro");
|
||||
|
||||
let stdout = ctx
|
||||
.run_type()
|
||||
.execute(micro)
|
||||
.args(["-plugin", "update"])
|
||||
.output_checked_utf8()?
|
||||
@@ -218,10 +209,7 @@ pub fn run_apm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Atom Package Manager");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(apm)
|
||||
.args(["upgrade", "--confirm=false"])
|
||||
.status_checked()
|
||||
ctx.execute(apm).args(["upgrade", "--confirm=false"]).status_checked()
|
||||
}
|
||||
|
||||
enum Aqua {
|
||||
@@ -251,7 +239,7 @@ fn get_aqua(ctx: &ExecutionContext) -> Result<Aqua> {
|
||||
let aqua = require("aqua")?;
|
||||
|
||||
// Check if `aqua --help` mentions "aqua". JetBrains Aqua does not, Aqua CLI does.
|
||||
let output = ctx.run_type().execute(&aqua).arg("--help").output_checked()?;
|
||||
let output = ctx.execute(&aqua).arg("--help").output_checked()?;
|
||||
|
||||
if String::from_utf8(output.stdout)?.contains("aqua") {
|
||||
debug!("Detected `aqua` as Aqua CLI");
|
||||
@@ -271,8 +259,8 @@ pub fn run_aqua(ctx: &ExecutionContext) -> Result<()> {
|
||||
println!("{}", t!("Updating aqua installed cli tools ..."));
|
||||
Ok(())
|
||||
} else {
|
||||
ctx.run_type().execute(&aqua).arg("update-aqua").status_checked()?;
|
||||
ctx.run_type().execute(&aqua).arg("update").status_checked()
|
||||
ctx.execute(&aqua).arg("update-aqua").status_checked()?;
|
||||
ctx.execute(&aqua).arg("update").status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,14 +268,14 @@ pub fn run_rustup(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rustup = require("rustup")?;
|
||||
|
||||
print_separator("rustup");
|
||||
ctx.run_type().execute(rustup).arg("update").status_checked()
|
||||
ctx.execute(rustup).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_rye(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rye = require("rye")?;
|
||||
|
||||
print_separator("Rye");
|
||||
ctx.run_type().execute(rye).args(["self", "update"]).status_checked()
|
||||
ctx.execute(rye).args(["self", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -296,7 +284,7 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("elan");
|
||||
|
||||
let disabled_error_msg = "self-update is disabled";
|
||||
let executor_output = ctx.run_type().execute(&elan).args(["self", "update"]).output()?;
|
||||
let executor_output = ctx.execute(&elan).args(["self", "update"]).output()?;
|
||||
match executor_output {
|
||||
ExecutorOutput::Wet(command_output) => {
|
||||
if command_output.status.success() {
|
||||
@@ -323,7 +311,7 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
ExecutorOutput::Dry => { /* nothing needed because in a dry run */ }
|
||||
}
|
||||
|
||||
ctx.run_type().execute(&elan).arg("update").status_checked()
|
||||
ctx.execute(&elan).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_juliaup(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -332,16 +320,13 @@ pub fn run_juliaup(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("juliaup");
|
||||
|
||||
if juliaup.canonicalize()?.is_descendant_of(&HOME_DIR) {
|
||||
ctx.run_type()
|
||||
.execute(&juliaup)
|
||||
.args(["self", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&juliaup).args(["self", "update"]).status_checked()?;
|
||||
}
|
||||
|
||||
ctx.run_type().execute(&juliaup).arg("update").status_checked()?;
|
||||
ctx.execute(&juliaup).arg("update").status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&juliaup).arg("gc").status_checked()?;
|
||||
ctx.execute(&juliaup).arg("gc").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -351,10 +336,9 @@ pub fn run_choosenim(ctx: &ExecutionContext) -> Result<()> {
|
||||
let choosenim = require("choosenim")?;
|
||||
|
||||
print_separator("choosenim");
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
run_type.execute(&choosenim).args(["update", "self"]).status_checked()?;
|
||||
run_type.execute(&choosenim).args(["update", "stable"]).status_checked()
|
||||
ctx.execute(&choosenim).args(["update", "self"]).status_checked()?;
|
||||
ctx.execute(&choosenim).args(["update", "stable"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_krew_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -362,7 +346,7 @@ pub fn run_krew_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Krew");
|
||||
|
||||
ctx.run_type().execute(krew).args(["upgrade"]).status_checked()
|
||||
ctx.execute(krew).args(["upgrade"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_gcloud_components_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -375,7 +359,6 @@ pub fn run_gcloud_components_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("gcloud");
|
||||
|
||||
let output = ctx
|
||||
.run_type()
|
||||
.execute(&gcloud)
|
||||
.args(["components", "update", "--quiet"])
|
||||
.output()?;
|
||||
@@ -411,10 +394,7 @@ pub fn run_jetpack(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Jetpack");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(jetpack)
|
||||
.args(["global", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(jetpack).args(["global", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -422,7 +402,7 @@ pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("rtcl");
|
||||
|
||||
ctx.run_type().execute(rupdate).status_checked()
|
||||
ctx.execute(rupdate).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -430,9 +410,9 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("OCaml Package Manager");
|
||||
|
||||
ctx.run_type().execute(&opam).arg("update").status_checked()?;
|
||||
ctx.execute(&opam).arg("update").status_checked()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(&opam);
|
||||
let mut command = ctx.execute(&opam);
|
||||
command.arg("upgrade");
|
||||
if ctx.config().yes(Step::Opam) {
|
||||
command.arg("--yes");
|
||||
@@ -440,7 +420,7 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&opam).arg("clean").status_checked()?;
|
||||
ctx.execute(&opam).arg("clean").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -457,10 +437,10 @@ pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let is_root_install = false;
|
||||
|
||||
let mut command = if is_root_install {
|
||||
ctx.run_type().execute(&vcpkg)
|
||||
ctx.execute(&vcpkg)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&vcpkg);
|
||||
c
|
||||
};
|
||||
@@ -525,7 +505,7 @@ fn run_vscode_compatible<const VSCODIUM: bool>(ctx: &ExecutionContext) -> Result
|
||||
"Visual Studio Code extensions"
|
||||
});
|
||||
|
||||
let mut cmd = ctx.run_type().execute(bin);
|
||||
let mut cmd = ctx.execute(bin);
|
||||
// If its VSCode (not VSCodium)
|
||||
if !VSCODIUM {
|
||||
// And we have configured use of a profile
|
||||
@@ -567,17 +547,14 @@ pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command_args.push("--quiet");
|
||||
}
|
||||
|
||||
ctx.run_type().execute(pipx).args(command_args).status_checked()
|
||||
ctx.execute(pipx).args(command_args).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pipxu_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let pipxu = require("pipxu")?;
|
||||
print_separator("pipxu");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(pipxu)
|
||||
.args(["upgrade", "--all"])
|
||||
.status_checked()
|
||||
ctx.execute(pipxu).args(["upgrade", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -599,7 +576,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let env_names = once(&base_env_name).chain(addl_env_names);
|
||||
|
||||
for env_name in env_names {
|
||||
let mut command = ctx.run_type().execute(&conda);
|
||||
let mut command = ctx.execute(&conda);
|
||||
command.args(["update", "--all", "-n", env_name]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -610,7 +587,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
// Update any environments given by path
|
||||
if let Some(env_paths) = ctx.config().conda_env_paths() {
|
||||
for env_path in env_paths.iter() {
|
||||
let mut command = ctx.run_type().execute(&conda);
|
||||
let mut command = ctx.execute(&conda);
|
||||
command.args(["update", "--all", "-p", env_path]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -621,7 +598,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
// Cleanup (conda clean) is global (not tied to a particular environment)
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(conda);
|
||||
let mut command = ctx.execute(conda);
|
||||
command.args(["clean", "--all"]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -638,15 +615,14 @@ pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
// Check if `pixi --help` mentions self-update, if yes, self-update must be enabled.
|
||||
// pixi self-update --help works regardless of whether the feature is enabled.
|
||||
let top_level_help_output = ctx.run_type().execute(&pixi).arg("--help").output_checked_utf8()?;
|
||||
let top_level_help_output = ctx.execute(&pixi).arg("--help").output_checked_utf8()?;
|
||||
|
||||
if top_level_help_output.stdout.contains("self-update") {
|
||||
let self_update_help_output = ctx
|
||||
.run_type()
|
||||
.execute(&pixi)
|
||||
.args(["self-update", "--help"])
|
||||
.output_checked_utf8()?;
|
||||
let mut cmd = ctx.run_type().execute(&pixi);
|
||||
let mut cmd = ctx.execute(&pixi);
|
||||
cmd.arg("self-update");
|
||||
// check if help mentions --no-release-note to check if it is supported
|
||||
if self_update_help_output.stdout.contains("--no-release-note") && !ctx.config().show_pixi_release_notes() {
|
||||
@@ -655,10 +631,7 @@ pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
cmd.status_checked()?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&pixi)
|
||||
.args(["global", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(&pixi).args(["global", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -666,7 +639,7 @@ pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Mamba");
|
||||
|
||||
let mut command = ctx.run_type().execute(&mamba);
|
||||
let mut command = ctx.execute(&mamba);
|
||||
command.args(["update", "--all", "-n", "base"]);
|
||||
if ctx.config().yes(Step::Mamba) {
|
||||
command.arg("--yes");
|
||||
@@ -674,7 +647,7 @@ pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&mamba);
|
||||
let mut command = ctx.execute(&mamba);
|
||||
command.args(["clean", "--all"]);
|
||||
if ctx.config().yes(Step::Mamba) {
|
||||
command.arg("--yes");
|
||||
@@ -689,10 +662,7 @@ pub fn run_miktex_packages_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let miktex = require("miktex")?;
|
||||
print_separator("miktex");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(miktex)
|
||||
.args(["packages", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(miktex).args(["packages", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pip3_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -770,8 +740,7 @@ pub fn run_pip3_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep("Does not run inside a virtual environment".to_string()).into());
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&python3)
|
||||
ctx.execute(&python3)
|
||||
.args(["-m", "pip", "install", "--upgrade", "--user", "pip"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -787,10 +756,7 @@ pub fn run_pip_review_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pip-review is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pip_review)
|
||||
.arg("--auto")
|
||||
.status_checked_with_codes(&[1])?;
|
||||
ctx.execute(pip_review).arg("--auto").status_checked_with_codes(&[1])?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -806,8 +772,7 @@ pub fn run_pip_review_local_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pip-review (local) is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pip_review)
|
||||
ctx.execute(pip_review)
|
||||
.arg("--local")
|
||||
.arg("--auto")
|
||||
.status_checked_with_codes(&[1])?;
|
||||
@@ -825,8 +790,7 @@ pub fn run_pipupgrade_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pipupgrade is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pipupgrade)
|
||||
ctx.execute(pipupgrade)
|
||||
.args(ctx.config().pipupgrade_arguments().split_whitespace())
|
||||
.status_checked()?;
|
||||
|
||||
@@ -844,14 +808,14 @@ pub fn run_stack_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let stack = require("stack")?;
|
||||
print_separator("stack");
|
||||
|
||||
ctx.run_type().execute(stack).arg("upgrade").status_checked()
|
||||
ctx.execute(stack).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_ghcup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let ghcup = require("ghcup")?;
|
||||
print_separator("ghcup");
|
||||
|
||||
ctx.run_type().execute(ghcup).arg("upgrade").status_checked()
|
||||
ctx.execute(ghcup).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -884,10 +848,10 @@ pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("TeX Live package manager");
|
||||
|
||||
let mut command = if directory_writable {
|
||||
ctx.run_type().execute(&tlmgr)
|
||||
ctx.execute(&tlmgr)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&tlmgr);
|
||||
c
|
||||
};
|
||||
@@ -902,7 +866,7 @@ pub fn run_chezmoi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("chezmoi");
|
||||
|
||||
ctx.run_type().execute(chezmoi).arg("update").status_checked()
|
||||
ctx.execute(chezmoi).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -911,14 +875,12 @@ pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("myrepos");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&myrepos)
|
||||
ctx.execute(&myrepos)
|
||||
.arg("--directory")
|
||||
.arg(&*HOME_DIR)
|
||||
.arg("checkout")
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&myrepos)
|
||||
ctx.execute(&myrepos)
|
||||
.arg("--directory")
|
||||
.arg(&*HOME_DIR)
|
||||
.arg("update")
|
||||
@@ -927,7 +889,7 @@ pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
pub fn run_custom_command(name: &str, command: &str, ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator(name);
|
||||
let mut exec = ctx.run_type().execute(shell());
|
||||
let mut exec = ctx.execute(shell());
|
||||
#[cfg(unix)]
|
||||
let command = if let Some(command) = command.strip_prefix("-i ") {
|
||||
exec.arg("-i");
|
||||
@@ -964,32 +926,31 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
// If self-update fails without sudo then there's probably an update
|
||||
let has_update = match ctx.run_type().execute(&composer).arg("self-update").output()? {
|
||||
let has_update = match ctx.execute(&composer).arg("self-update").output()? {
|
||||
ExecutorOutput::Wet(output) => !output.status.success(),
|
||||
_ => false
|
||||
};
|
||||
|
||||
if has_update {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg(&composer)
|
||||
.arg("self-update")
|
||||
.status_checked()?;
|
||||
}
|
||||
} else {
|
||||
ctx.run_type().execute(&composer).arg("self-update").status_checked()?;
|
||||
ctx.execute(&composer).arg("self-update").status_checked()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let output = ctx.run_type().execute(&composer).args(["global", "update"]).output()?;
|
||||
let output = ctx.execute(&composer).args(["global", "update"]).output()?;
|
||||
if let ExecutorOutput::Wet(output) = output {
|
||||
let output: Utf8Output = output.try_into()?;
|
||||
print!("{}\n{}", output.stdout, output.stderr);
|
||||
if output.stdout.contains("valet") || output.stderr.contains("valet") {
|
||||
if let Some(valet) = which("valet") {
|
||||
ctx.run_type().execute(valet).arg("install").status_checked()?;
|
||||
ctx.execute(valet).arg("install").status_checked()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1003,7 +964,6 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
// Skip when the `dotnet tool list` subcommand fails.
|
||||
// (This is expected when a dotnet runtime is installed but no SDK.)
|
||||
let output = match ctx
|
||||
.run_type()
|
||||
.execute(&dotnet)
|
||||
.args(["tool", "list", "--global"])
|
||||
// dotnet will print a greeting message on its first run, from this question:
|
||||
@@ -1052,8 +1012,7 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
for package in packages {
|
||||
let package_name = package.split_whitespace().next().unwrap();
|
||||
ctx.run_type()
|
||||
.execute(&dotnet)
|
||||
ctx.execute(&dotnet)
|
||||
.args(["tool", "update", package_name, "--global"])
|
||||
.status_checked()
|
||||
.with_context(|| format!("Failed to update .NET package {package_name:?}"))?;
|
||||
@@ -1090,7 +1049,7 @@ fn get_hx(ctx: &ExecutionContext) -> Result<Hx> {
|
||||
let hx = require("hx")?;
|
||||
|
||||
// Check if `hx --help` mentions "helix". Helix does, hx (hexdump alternative) doesn't.
|
||||
let output = ctx.run_type().execute(&hx).arg("--help").output_checked()?;
|
||||
let output = ctx.execute(&hx).arg("--help").output_checked()?;
|
||||
|
||||
if String::from_utf8(output.stdout)?.contains("helix") {
|
||||
debug!("Detected `hx` as Helix");
|
||||
@@ -1106,14 +1065,12 @@ pub fn run_helix_grammars(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Helix");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&helix)
|
||||
ctx.execute(&helix)
|
||||
.args(["--grammar", "fetch"])
|
||||
.status_checked()
|
||||
.with_context(|| "Failed to download helix grammars!")?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&helix)
|
||||
ctx.execute(&helix)
|
||||
.args(["--grammar", "build"])
|
||||
.status_checked()
|
||||
.with_context(|| "Failed to build helix grammars!")?;
|
||||
@@ -1126,17 +1083,14 @@ pub fn run_raco_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Racket Package Manager"));
|
||||
|
||||
ctx.run_type()
|
||||
.execute(raco)
|
||||
.args(["pkg", "update", "--all"])
|
||||
.status_checked()
|
||||
ctx.execute(raco).args(["pkg", "update", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn bin_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let bin = require("bin")?;
|
||||
|
||||
print_separator("Bin");
|
||||
ctx.run_type().execute(bin).arg("update").status_checked()
|
||||
ctx.execute(bin).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn spicetify_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1144,7 +1098,7 @@ pub fn spicetify_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
let spicetify = require("spicetify").or(require("spicetify-cli"))?;
|
||||
|
||||
print_separator("Spicetify");
|
||||
ctx.run_type().execute(spicetify).arg("upgrade").status_checked()
|
||||
ctx.execute(spicetify).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_ghcli_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1156,8 +1110,7 @@ pub fn run_ghcli_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
print_separator(t!("GitHub CLI Extensions"));
|
||||
ctx.run_type()
|
||||
.execute(&gh)
|
||||
ctx.execute(&gh)
|
||||
.args(["extension", "upgrade", "--all"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -1167,7 +1120,7 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Julia Packages"));
|
||||
|
||||
let mut executor = ctx.run_type().execute(julia);
|
||||
let mut executor = ctx.execute(julia);
|
||||
|
||||
executor.arg(if ctx.config().julia_use_startup_file() {
|
||||
"--startup-file=yes"
|
||||
@@ -1185,7 +1138,7 @@ pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let no_repo = "no repositories found";
|
||||
let mut success = true;
|
||||
let mut exec = ctx.run_type().execute(helm);
|
||||
let mut exec = ctx.execute(helm);
|
||||
if let Err(e) = exec.arg("repo").arg("update").status_checked() {
|
||||
error!("Updating repositories failed: {e}");
|
||||
success = match exec.output_checked_utf8() {
|
||||
@@ -1208,7 +1161,7 @@ pub fn run_stew(ctx: &ExecutionContext) -> Result<()> {
|
||||
let stew = require("stew")?;
|
||||
|
||||
print_separator("stew");
|
||||
ctx.run_type().execute(stew).args(["upgrade", "--all"]).status_checked()
|
||||
ctx.execute(stew).args(["upgrade", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_bob(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1216,7 +1169,7 @@ pub fn run_bob(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bob");
|
||||
|
||||
ctx.run_type().execute(bob).args(["update", "--all"]).status_checked()
|
||||
ctx.execute(bob).args(["update", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1225,7 +1178,7 @@ pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Certbot");
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg(certbot);
|
||||
cmd.arg("renew");
|
||||
|
||||
@@ -1238,7 +1191,7 @@ pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn run_freshclam(ctx: &ExecutionContext) -> Result<()> {
|
||||
let freshclam = require("freshclam")?;
|
||||
print_separator(t!("Update ClamAV Database(FreshClam)"));
|
||||
ctx.run_type().execute(freshclam).status_checked()
|
||||
ctx.execute(freshclam).status_checked()
|
||||
}
|
||||
|
||||
/// Involve `pio upgrade` to update PlatformIO core.
|
||||
@@ -1258,7 +1211,7 @@ pub fn run_platform_io(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("PlatformIO Core");
|
||||
|
||||
ctx.run_type().execute(bin_path).arg("upgrade").status_checked()
|
||||
ctx.execute(bin_path).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
/// Run `lensfun-update-data` to update lensfun database.
|
||||
@@ -1272,16 +1225,14 @@ pub fn run_lensfun_update_data(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().lensfun_use_sudo() {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
print_separator(SEPARATOR);
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg(lensfun_update_data)
|
||||
// `lensfun-update-data` returns 1 when there is no update available
|
||||
// which should be considered success
|
||||
.status_checked_with_codes(&[EXIT_CODE_WHEN_NO_UPDATE])
|
||||
} else {
|
||||
print_separator(SEPARATOR);
|
||||
ctx.run_type()
|
||||
.execute(lensfun_update_data)
|
||||
ctx.execute(lensfun_update_data)
|
||||
.status_checked_with_codes(&[EXIT_CODE_WHEN_NO_UPDATE])
|
||||
}
|
||||
}
|
||||
@@ -1390,10 +1341,7 @@ pub fn run_poetry(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
print_separator("Poetry");
|
||||
ctx.run_type()
|
||||
.execute(&poetry)
|
||||
.args(["self", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(&poetry).args(["self", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1406,11 +1354,7 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
// To check if this feature is enabled or not, different version of `uv` need
|
||||
// different approaches, we need to know the version first and handle them
|
||||
// separately.
|
||||
let uv_version_output = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.arg("--version")
|
||||
.output_checked_utf8()?;
|
||||
let uv_version_output = ctx.execute(&uv_exec).arg("--version").output_checked_utf8()?;
|
||||
// Multiple possible output formats are possible according to uv source code
|
||||
//
|
||||
// https://github.com/astral-sh/uv/blob/6b7f60c1eaa840c2e933a0fb056ab46f99c991a5/crates/uv-cli/src/version.rs#L28-L42
|
||||
@@ -1445,18 +1389,10 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
// For uv before version 0.4.25 (exclusive), the `self` sub-command only
|
||||
// exists under the `self-update` feature, we run `uv self --help` to check
|
||||
// the feature gate.
|
||||
let self_update_feature_enabled = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "--help"])
|
||||
.output_checked()
|
||||
.is_ok();
|
||||
let self_update_feature_enabled = ctx.execute(&uv_exec).args(["self", "--help"]).output_checked().is_ok();
|
||||
|
||||
if self_update_feature_enabled {
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&uv_exec).args(["self", "update"]).status_checked()?;
|
||||
}
|
||||
} else {
|
||||
// After 0.4.25 (inclusive), running `uv self` succeeds regardless of the
|
||||
@@ -1482,7 +1418,6 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
];
|
||||
|
||||
let output = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "update"])
|
||||
// `output()` captures the output so that users won't see it for now.
|
||||
@@ -1510,17 +1445,13 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
};
|
||||
|
||||
// 2. Update the installed tools
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
ctx.execute(&uv_exec)
|
||||
.args(["tool", "upgrade", "--all"])
|
||||
.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
// 3. Prune cache
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["cache", "prune"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&uv_exec).args(["cache", "prune"]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1532,7 +1463,7 @@ pub fn run_zvm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("ZVM");
|
||||
|
||||
ctx.run_type().execute(zvm).arg("upgrade").status_checked()
|
||||
ctx.execute(zvm).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1540,7 +1471,7 @@ pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bun");
|
||||
|
||||
ctx.run_type().execute(bun).arg("upgrade").status_checked()
|
||||
ctx.execute(bun).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1560,16 +1491,14 @@ pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
for zig_version in config.zigup_target_versions() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
ctx.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("fetch")
|
||||
.arg(&zig_version)
|
||||
.status_checked()?;
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
ctx.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("keep")
|
||||
.arg(&zig_version)
|
||||
@@ -1578,11 +1507,7 @@ pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(zigup)
|
||||
.args(&path_args)
|
||||
.arg("clean")
|
||||
.status_checked()?;
|
||||
ctx.execute(zigup).args(&path_args).arg("clean").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1632,7 +1557,7 @@ fn run_jetbrains_ide_generic<const IS_JETBRAINS: bool>(ctx: &ExecutionContext, b
|
||||
print_separator(format!("{prefix}{name} plugins"));
|
||||
|
||||
// The `update` command is undocumented, but tested on all of the below.
|
||||
let output = ctx.run_type().execute(&bin).arg("update").output()?;
|
||||
let output = ctx.execute(&bin).arg("update").output()?;
|
||||
let output = match output {
|
||||
ExecutorOutput::Dry => return Ok(()),
|
||||
ExecutorOutput::Wet(output) => output,
|
||||
@@ -1765,5 +1690,5 @@ pub fn run_yazi(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Yazi packages");
|
||||
|
||||
ctx.run_type().execute(ya).args(["pkg", "upgrade"]).status_checked()
|
||||
ctx.execute(ya).args(["pkg", "upgrade"]).status_checked()
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn run_go_global_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("go-global-update");
|
||||
|
||||
ctx.run_type().execute(go_global_update).status_checked()
|
||||
ctx.execute(go_global_update).status_checked()
|
||||
}
|
||||
|
||||
/// <https://github.com/nao1215/gup>
|
||||
@@ -24,7 +24,7 @@ pub fn run_go_gup(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("gup");
|
||||
|
||||
ctx.run_type().execute(gup).arg("update").status_checked()
|
||||
ctx.execute(gup).arg("update").status_checked()
|
||||
}
|
||||
|
||||
/// Get the path of a Go binary.
|
||||
|
||||
@@ -13,10 +13,7 @@ pub fn upgrade_kak_plug(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Kakoune");
|
||||
|
||||
// TODO: Why supress output for this command?
|
||||
ctx.run_type()
|
||||
.execute(kak)
|
||||
.args(["-ui", "dummy", "-e", UPGRADE_KAK])
|
||||
.output()?;
|
||||
ctx.execute(kak).args(["-ui", "dummy", "-e", UPGRADE_KAK]).output()?;
|
||||
|
||||
println!("{}", t!("Plugins upgraded"));
|
||||
|
||||
|
||||
@@ -94,13 +94,9 @@ impl NPM {
|
||||
let args = ["update", self.global_location_arg()];
|
||||
if use_sudo {
|
||||
let sudo = require_option(ctx.sudo().clone(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&self.command)
|
||||
.args(args)
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(&self.command).args(args).status_checked()?;
|
||||
} else {
|
||||
ctx.run_type().execute(&self.command).args(args).status_checked()?;
|
||||
ctx.execute(&self.command).args(args).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -158,13 +154,12 @@ impl Yarn {
|
||||
|
||||
if use_sudo {
|
||||
let sudo = require_option(ctx.sudo().clone(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg(self.yarn.as_ref().unwrap_or(&self.command))
|
||||
.args(args)
|
||||
.status_checked()?;
|
||||
} else {
|
||||
ctx.run_type().execute(&self.command).args(args).status_checked()?;
|
||||
ctx.execute(&self.command).args(args).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -245,11 +240,7 @@ impl Deno {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&self.command)
|
||||
.arg("upgrade")
|
||||
.args(args)
|
||||
.status_checked()?;
|
||||
ctx.execute(&self.command).arg("upgrade").args(args).status_checked()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -376,7 +367,6 @@ pub fn run_volta_packages_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
let list_output = ctx
|
||||
.run_type()
|
||||
.execute(&volta)
|
||||
.args(["list", "--format=plain"])
|
||||
.output_checked_utf8()?
|
||||
@@ -400,10 +390,7 @@ pub fn run_volta_packages_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
for package in &installed_packages {
|
||||
ctx.run_type()
|
||||
.execute(&volta)
|
||||
.args(["install", package])
|
||||
.status_checked()?;
|
||||
ctx.execute(&volta).args(["install", package]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let is_nala = pkg.ends_with("nala");
|
||||
|
||||
let mut command = ctx.run_type().execute(&pkg);
|
||||
let mut command = ctx.execute(&pkg);
|
||||
command.arg("upgrade");
|
||||
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -23,10 +23,10 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if !is_nala && ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&pkg).arg("clean").status_checked()?;
|
||||
ctx.execute(&pkg).arg("clean").status_checked()?;
|
||||
|
||||
let apt = require("apt")?;
|
||||
let mut command = ctx.run_type().execute(apt);
|
||||
let mut command = ctx.execute(apt);
|
||||
command.arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
|
||||
@@ -33,13 +33,12 @@ pub struct YayParu {
|
||||
impl ArchPackageManager for YayParu {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().show_arch_news() {
|
||||
ctx.run_type()
|
||||
.execute(&self.executable)
|
||||
ctx.execute(&self.executable)
|
||||
.arg("-Pw")
|
||||
.status_checked_with_codes(&[1, 0])?;
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
|
||||
command
|
||||
.arg("--pacman")
|
||||
@@ -54,7 +53,7 @@ impl ArchPackageManager for YayParu {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
command.arg("--pacman").arg(&self.pacman).arg("-Scc");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
@@ -81,7 +80,7 @@ pub struct GarudaUpdate {
|
||||
|
||||
impl ArchPackageManager for GarudaUpdate {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
|
||||
command
|
||||
.env("PATH", get_execution_path())
|
||||
@@ -112,7 +111,7 @@ pub struct Trizen {
|
||||
|
||||
impl ArchPackageManager for Trizen {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
|
||||
command
|
||||
.arg("-Syu")
|
||||
@@ -125,7 +124,7 @@ impl ArchPackageManager for Trizen {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
command.arg("-Sc");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
@@ -152,7 +151,7 @@ pub struct Pacman {
|
||||
impl ArchPackageManager for Pacman {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), "sudo is required to run pacman".into())?;
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command
|
||||
.arg(&self.executable)
|
||||
.arg("-Syu")
|
||||
@@ -163,7 +162,7 @@ impl ArchPackageManager for Pacman {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(&self.executable).arg("-Scc");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
@@ -197,7 +196,7 @@ impl Pikaur {
|
||||
|
||||
impl ArchPackageManager for Pikaur {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
|
||||
command
|
||||
.arg("-Syu")
|
||||
@@ -211,7 +210,7 @@ impl ArchPackageManager for Pikaur {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
command.arg("-Sc");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
@@ -236,7 +235,7 @@ impl Pamac {
|
||||
}
|
||||
impl ArchPackageManager for Pamac {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
|
||||
command
|
||||
.arg("upgrade")
|
||||
@@ -250,7 +249,7 @@ impl ArchPackageManager for Pamac {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
let mut command = ctx.execute(&self.executable);
|
||||
command.arg("clean");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--no-confirm");
|
||||
@@ -278,11 +277,7 @@ impl ArchPackageManager for Aura {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
use semver::Version;
|
||||
|
||||
let version_cmd_output = ctx
|
||||
.run_type()
|
||||
.execute(&self.executable)
|
||||
.arg("--version")
|
||||
.output_checked_utf8()?;
|
||||
let version_cmd_output = ctx.execute(&self.executable).arg("--version").output_checked_utf8()?;
|
||||
// Output will be something like: "aura x.x.x\n"
|
||||
let version_cmd_stdout = version_cmd_output.stdout;
|
||||
let version_str = version_cmd_stdout.trim_start_matches("aura ").trim_end();
|
||||
@@ -295,7 +290,7 @@ impl ArchPackageManager for Aura {
|
||||
let version_no_sudo = Version::new(4, 0, 6);
|
||||
|
||||
if version >= version_no_sudo {
|
||||
let mut cmd = ctx.run_type().execute(&self.executable);
|
||||
let mut cmd = ctx.execute(&self.executable);
|
||||
cmd.arg("-Au")
|
||||
.args(ctx.config().aura_aur_arguments().split_whitespace());
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -303,7 +298,7 @@ impl ArchPackageManager for Aura {
|
||||
}
|
||||
cmd.status_checked()?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(&self.executable);
|
||||
let mut cmd = ctx.execute(&self.executable);
|
||||
cmd.arg("-Syu")
|
||||
.args(ctx.config().aura_pacman_arguments().split_whitespace());
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -316,7 +311,7 @@ impl ArchPackageManager for Aura {
|
||||
t!("Aura(<0.4.6) requires sudo installed to work with AUR packages").to_string(),
|
||||
)?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg(&self.executable)
|
||||
.arg("-Au")
|
||||
.args(ctx.config().aura_aur_arguments().split_whitespace());
|
||||
@@ -325,7 +320,7 @@ impl ArchPackageManager for Aura {
|
||||
}
|
||||
cmd.status_checked()?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg(&self.executable)
|
||||
.arg("-Syu")
|
||||
.args(ctx.config().aura_pacman_arguments().split_whitespace());
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::process::Command;
|
||||
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
print_separator(t!("DragonFly BSD Packages"));
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.args(["/usr/local/sbin/pkg", "upgrade"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-y");
|
||||
|
||||
@@ -10,8 +10,7 @@ use std::process::Command;
|
||||
pub fn upgrade_freebsd(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
print_separator(t!("FreeBSD Update"));
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["/usr/sbin/freebsd-update", "fetch", "install"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -20,7 +19,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
print_separator(t!("FreeBSD Packages"));
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
|
||||
command.args(["/usr/sbin/pkg", "upgrade"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
|
||||
@@ -177,7 +177,7 @@ impl Distribution {
|
||||
fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]);
|
||||
ctx.execute(sudo).args(["brl", "update"]);
|
||||
|
||||
let output = Command::new("brl").arg("list").output_checked_utf8()?;
|
||||
debug!("brl list: {:?} {:?}", output.stdout, output.stderr);
|
||||
@@ -202,44 +202,44 @@ fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apk = require("apk")?;
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
ctx.execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_chimera_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apk = require("apk")?;
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
ctx.execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_wolfi_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apk = require("apk")?;
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
ctx.execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(bootc) = which("bootc") {
|
||||
if ctx.config().bootc() {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
return ctx.run_type().execute(sudo).arg(&bootc).arg("upgrade").status_checked();
|
||||
return ctx.execute(sudo).arg(&bootc).arg("upgrade").status_checked();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ostree) = which("rpm-ostree") {
|
||||
if ctx.config().rpm_ostree() {
|
||||
let mut command = ctx.run_type().execute(ostree);
|
||||
let mut command = ctx.execute(ostree);
|
||||
command.arg("upgrade");
|
||||
return command.status_checked();
|
||||
}
|
||||
};
|
||||
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command
|
||||
.arg(which("dnf").unwrap_or_else(|| Path::new("yum").to_path_buf()))
|
||||
.arg(if ctx.config().redhat_distro_sync() {
|
||||
@@ -264,7 +264,7 @@ fn upgrade_nobara(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let pkg_manager = require("dnf")?;
|
||||
|
||||
let mut update_command = ctx.run_type().execute(sudo);
|
||||
let mut update_command = ctx.execute(sudo);
|
||||
update_command.arg(&pkg_manager);
|
||||
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -281,7 +281,7 @@ fn upgrade_nobara(ctx: &ExecutionContext) -> Result<()> {
|
||||
]);
|
||||
update_command.arg("--refresh").status_checked()?;
|
||||
|
||||
let mut upgrade_command = ctx.run_type().execute(sudo);
|
||||
let mut upgrade_command = ctx.execute(sudo);
|
||||
upgrade_command.arg(&pkg_manager);
|
||||
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -298,20 +298,20 @@ fn upgrade_nilrt(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let opkg = require("opkg")?;
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&opkg).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&opkg).arg("upgrade").status_checked()
|
||||
ctx.execute(sudo).arg(&opkg).arg("update").status_checked()?;
|
||||
ctx.execute(sudo).arg(&opkg).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_fedora_immutable(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(bootc) = which("bootc") {
|
||||
if ctx.config().bootc() {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
return ctx.run_type().execute(sudo).arg(&bootc).arg("upgrade").status_checked();
|
||||
return ctx.execute(sudo).arg(&bootc).arg("upgrade").status_checked();
|
||||
}
|
||||
}
|
||||
|
||||
let ostree = require("rpm-ostree")?;
|
||||
let mut command = ctx.run_type().execute(ostree);
|
||||
let mut command = ctx.execute(ostree);
|
||||
command.arg("upgrade");
|
||||
command.status_checked()?;
|
||||
Ok(())
|
||||
@@ -319,19 +319,16 @@ fn upgrade_fedora_immutable(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]).status_checked()?;
|
||||
ctx.execute(sudo).args(["brl", "update"]).status_checked()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["zypper", "refresh"])
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).args(["zypper", "refresh"]).status_checked()?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg("zypper");
|
||||
cmd.arg(if ctx.config().suse_dup() {
|
||||
"dist-upgrade"
|
||||
@@ -349,12 +346,9 @@ fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_opensuse_tumbleweed(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["zypper", "refresh"])
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).args(["zypper", "refresh"]).status_checked()?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.args(["zypper", "dist-upgrade"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-y");
|
||||
@@ -367,7 +361,7 @@ fn upgrade_opensuse_tumbleweed(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_suse_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg("transactional-update");
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-n");
|
||||
@@ -380,7 +374,7 @@ fn upgrade_suse_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
|
||||
command.arg(which("dnf").unwrap()).arg("upgrade");
|
||||
|
||||
@@ -399,7 +393,7 @@ fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_pclinuxos(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut command_update = ctx.run_type().execute(sudo);
|
||||
let mut command_update = ctx.execute(sudo);
|
||||
|
||||
command_update.arg(which("apt-get").unwrap()).arg("update");
|
||||
|
||||
@@ -413,7 +407,7 @@ fn upgrade_pclinuxos(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
command_update.status_checked()?;
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg(which("apt-get").unwrap());
|
||||
cmd.arg("dist-upgrade");
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -427,14 +421,14 @@ fn upgrade_pclinuxos(ctx: &ExecutionContext) -> Result<()> {
|
||||
fn upgrade_vanilla(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apx = require("apx")?;
|
||||
|
||||
let mut update = ctx.run_type().execute(&apx);
|
||||
let mut update = ctx.execute(&apx);
|
||||
update.args(["update", "--all"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
update.arg("-y");
|
||||
}
|
||||
update.status_checked()?;
|
||||
|
||||
let mut upgrade = ctx.run_type().execute(&apx);
|
||||
let mut upgrade = ctx.execute(&apx);
|
||||
update.args(["upgrade", "--all"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
upgrade.arg("-y");
|
||||
@@ -446,14 +440,14 @@ fn upgrade_vanilla(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.args(["xbps-install", "-Su", "xbps"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.args(["xbps-install", "-u"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
@@ -464,24 +458,17 @@ fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
if let Some(layman) = which("layman") {
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(layman)
|
||||
.args(["-s", "ALL"])
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(layman).args(["-s", "ALL"]).status_checked()?;
|
||||
}
|
||||
|
||||
println!("{}", t!("Syncing portage"));
|
||||
if let Some(ego) = which("ego") {
|
||||
// The Funtoo team doesn't reccomend running both ego sync and emerge --sync
|
||||
run_type.execute(sudo).arg(ego).arg("sync").status_checked()?;
|
||||
ctx.execute(sudo).arg(ego).arg("sync").status_checked()?;
|
||||
} else {
|
||||
run_type
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["emerge", "--sync"])
|
||||
.args(
|
||||
ctx.config()
|
||||
@@ -493,11 +480,10 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
if let Some(eix_update) = which("eix-update") {
|
||||
run_type.execute(sudo).arg(eix_update).status_checked()?;
|
||||
ctx.execute(sudo).arg(eix_update).status_checked()?;
|
||||
}
|
||||
|
||||
run_type
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg("emerge")
|
||||
.args(
|
||||
ctx.config()
|
||||
@@ -533,8 +519,8 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
// MIST does not require `sudo`
|
||||
if is_mist {
|
||||
ctx.run_type().execute(&apt).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(&apt).arg("upgrade").status_checked()?;
|
||||
ctx.execute(&apt).arg("update").status_checked()?;
|
||||
ctx.execute(&apt).arg("upgrade").status_checked()?;
|
||||
|
||||
// Simply return as MIST does not have `clean` and `autoremove`
|
||||
// subcommands, neither the `-y` option (for now maybe?).
|
||||
@@ -543,14 +529,13 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
if !is_nala {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg(&apt)
|
||||
.arg("update")
|
||||
.status_checked_with_codes(&[0, 100])?;
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(&apt);
|
||||
if is_nala {
|
||||
command.arg("upgrade");
|
||||
@@ -566,9 +551,9 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("clean").status_checked()?;
|
||||
ctx.execute(sudo).arg(&apt).arg("clean").status_checked()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(&apt).arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
@@ -584,11 +569,11 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("deb-get");
|
||||
|
||||
ctx.run_type().execute(&deb_get).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(&deb_get).arg("upgrade").status_checked()?;
|
||||
ctx.execute(&deb_get).arg("update").status_checked()?;
|
||||
ctx.execute(&deb_get).arg("upgrade").status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let output = ctx.run_type().execute(&deb_get).arg("clean").output_checked()?;
|
||||
let output = ctx.execute(&deb_get).arg("clean").output_checked()?;
|
||||
// Swallow the output, as it's very noisy and not useful.
|
||||
// The output is automatically printed as part of `output_checked` when an error occurs.
|
||||
println!("{}", t!("<output from `deb-get clean` omitted>"));
|
||||
@@ -600,7 +585,7 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg("eopkg");
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-y");
|
||||
@@ -615,7 +600,7 @@ pub fn run_am(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("AM");
|
||||
|
||||
let mut am = ctx.run_type().execute(am);
|
||||
let mut am = ctx.execute(am);
|
||||
|
||||
if ctx.config().yes(Step::AM) {
|
||||
am.arg("-U");
|
||||
@@ -631,7 +616,7 @@ pub fn run_appman(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("appman");
|
||||
|
||||
ctx.run_type().execute(appman).arg("-u").status_checked()
|
||||
ctx.execute(appman).arg("-u").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -639,12 +624,12 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("pacdef");
|
||||
|
||||
let output = ctx.run_type().execute(&pacdef).arg("version").output_checked()?;
|
||||
let output = ctx.execute(&pacdef).arg("version").output_checked()?;
|
||||
let string = String::from_utf8(output.stdout)?;
|
||||
let new_version = string.contains("version: 1");
|
||||
|
||||
if new_version {
|
||||
let mut cmd = ctx.run_type().execute(&pacdef);
|
||||
let mut cmd = ctx.execute(&pacdef);
|
||||
cmd.args(["package", "sync"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("--noconfirm");
|
||||
@@ -652,12 +637,9 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
||||
cmd.status_checked()?;
|
||||
|
||||
println!();
|
||||
ctx.run_type()
|
||||
.execute(&pacdef)
|
||||
.args(["package", "review"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&pacdef).args(["package", "review"]).status_checked()?;
|
||||
} else {
|
||||
let mut cmd = ctx.run_type().execute(&pacdef);
|
||||
let mut cmd = ctx.execute(&pacdef);
|
||||
cmd.arg("sync");
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("--noconfirm");
|
||||
@@ -666,7 +648,7 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
||||
cmd.status_checked()?;
|
||||
|
||||
println!();
|
||||
ctx.run_type().execute(&pacdef).arg("review").status_checked()?;
|
||||
ctx.execute(&pacdef).arg("review").status_checked()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -676,8 +658,8 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Pacstall");
|
||||
|
||||
let mut update_cmd = ctx.run_type().execute(&pacstall);
|
||||
let mut upgrade_cmd = ctx.run_type().execute(pacstall);
|
||||
let mut update_cmd = ctx.execute(&pacstall);
|
||||
let mut upgrade_cmd = ctx.execute(pacstall);
|
||||
|
||||
if ctx.config().yes(Step::Pacstall) {
|
||||
update_cmd.arg("-P");
|
||||
@@ -696,8 +678,7 @@ pub fn run_packer_nu(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("packer.nu");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(nu)
|
||||
ctx.execute(nu)
|
||||
.env("PWD", "/")
|
||||
.env("NU_PACKER_HOME", packer_home)
|
||||
.args([
|
||||
@@ -709,7 +690,7 @@ pub fn run_packer_nu(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.args(["swupd", "update"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("--assume=yes");
|
||||
@@ -721,27 +702,21 @@ fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type().execute(sudo).args(["cave", "sync"]).status_checked()?;
|
||||
ctx.execute(sudo).args(["cave", "sync"]).status_checked()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
|
||||
.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["cave", "purge", "-x"])
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).args(["cave", "purge", "-x"]).status_checked()?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["cave", "fix-linkage", "-x", "--", "-Cs"])
|
||||
.status_checked()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["eclectic", "config", "interactive"])
|
||||
.status_checked()?;
|
||||
|
||||
@@ -750,7 +725,7 @@ fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_nixos(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.args(["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"]);
|
||||
|
||||
if let Some(args) = ctx.config().nix_arguments() {
|
||||
@@ -759,8 +734,7 @@ fn upgrade_nixos(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
|
||||
.status_checked()?;
|
||||
}
|
||||
@@ -778,12 +752,8 @@ fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let pkcon = which("pkcon").unwrap();
|
||||
// pkcon ignores update with update and refresh provided together
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&pkcon)
|
||||
.arg("refresh")
|
||||
.status_checked()?;
|
||||
let mut exe = ctx.run_type().execute(sudo);
|
||||
ctx.execute(sudo).arg(&pkcon).arg("refresh").status_checked()?;
|
||||
let mut exe = ctx.execute(sudo);
|
||||
let cmd = exe.arg(&pkcon).arg("update");
|
||||
if ctx.config().yes(Step::System) {
|
||||
cmd.arg("-y");
|
||||
@@ -846,7 +816,7 @@ pub fn run_needrestart(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Check for needed restarts"));
|
||||
|
||||
ctx.run_type().execute(sudo).arg(needrestart).status_checked()?;
|
||||
ctx.execute(sudo).arg(needrestart).status_checked()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -860,12 +830,9 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Firmware upgrades"));
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&fwupdmgr)
|
||||
.arg("refresh")
|
||||
.status_checked_with_codes(&[2])?;
|
||||
ctx.execute(&fwupdmgr).arg("refresh").status_checked_with_codes(&[2])?;
|
||||
|
||||
let mut updmgr = ctx.run_type().execute(&fwupdmgr);
|
||||
let mut updmgr = ctx.execute(&fwupdmgr);
|
||||
|
||||
if ctx.config().firmware_upgrade() {
|
||||
updmgr.arg("update");
|
||||
@@ -883,21 +850,20 @@ pub fn run_flatpak(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let cleanup = ctx.config().cleanup();
|
||||
let yes = ctx.config().yes(Step::Flatpak);
|
||||
let run_type = ctx.run_type();
|
||||
print_separator("Flatpak User Packages");
|
||||
|
||||
let mut update_args = vec!["update", "--user"];
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
ctx.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--user", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&cleanup_args).status_checked()?;
|
||||
ctx.execute(&flatpak).args(&cleanup_args).status_checked()?;
|
||||
}
|
||||
|
||||
print_separator(t!("Flatpak System Packages"));
|
||||
@@ -906,34 +872,26 @@ pub fn run_flatpak(ctx: &ExecutionContext) -> Result<()> {
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(&flatpak)
|
||||
.args(&update_args)
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(&flatpak).args(&update_args).status_checked()?;
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(flatpak)
|
||||
.args(&cleanup_args)
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(flatpak).args(&cleanup_args).status_checked()?;
|
||||
}
|
||||
} else {
|
||||
let mut update_args = vec!["update", "--system"];
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
ctx.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type.execute(flatpak).args(&cleanup_args).status_checked()?;
|
||||
ctx.execute(flatpak).args(&cleanup_args).status_checked()?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,7 +907,7 @@ pub fn run_snap(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
print_separator("snap");
|
||||
|
||||
ctx.run_type().execute(sudo).arg(snap).arg("refresh").status_checked()
|
||||
ctx.execute(sudo).arg(snap).arg("refresh").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pihole_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -959,7 +917,7 @@ pub fn run_pihole_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("pihole");
|
||||
|
||||
ctx.run_type().execute(sudo).arg(pihole).arg("-up").status_checked()
|
||||
ctx.execute(sudo).arg(pihole).arg("-up").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -967,7 +925,7 @@ pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("protonup");
|
||||
|
||||
let mut cmd = ctx.run_type().execute(protonup);
|
||||
let mut cmd = ctx.execute(protonup);
|
||||
if ctx.config().yes(Step::Protonup) {
|
||||
cmd.arg("--yes");
|
||||
}
|
||||
@@ -982,7 +940,7 @@ pub fn run_distrobox_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Distrobox");
|
||||
match (
|
||||
match (
|
||||
ctx.run_type().execute(distrobox).arg("upgrade"),
|
||||
ctx.execute(distrobox).arg("upgrade"),
|
||||
ctx.config().distrobox_containers(),
|
||||
) {
|
||||
(r, Some(c)) => {
|
||||
@@ -1007,18 +965,10 @@ pub fn run_dkp_pacman_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Devkitpro pacman");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&dkp_pacman)
|
||||
.arg("-Syu")
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(&dkp_pacman).arg("-Syu").status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&dkp_pacman)
|
||||
.arg("-Scc")
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).arg(&dkp_pacman).arg("-Scc").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1032,7 +982,7 @@ pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if let Ok(etc_update) = require("etc-update") {
|
||||
print_separator(t!("Configuration update"));
|
||||
ctx.run_type().execute(sudo).arg(etc_update).status_checked()?;
|
||||
ctx.execute(sudo).arg(etc_update).status_checked()?;
|
||||
} else if let Ok(pacdiff) = require("pacdiff") {
|
||||
if std::env::var("DIFFPROG").is_err() {
|
||||
require("vim")?;
|
||||
@@ -1050,7 +1000,7 @@ pub fn run_lure_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("LURE");
|
||||
|
||||
let mut exe = ctx.run_type().execute(lure);
|
||||
let mut exe = ctx.execute(lure);
|
||||
|
||||
if ctx.config().yes(Step::Lure) {
|
||||
exe.args(["-i=false", "up"]);
|
||||
@@ -1064,7 +1014,7 @@ pub fn run_lure_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn run_waydroid(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let waydroid = require("waydroid")?;
|
||||
let status = ctx.run_type().execute(&waydroid).arg("status").output_checked_utf8()?;
|
||||
let status = ctx.execute(&waydroid).arg("status").output_checked_utf8()?;
|
||||
// example output of `waydroid status`:
|
||||
//
|
||||
// ```sh
|
||||
@@ -1102,11 +1052,7 @@ pub fn run_waydroid(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
}
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&waydroid)
|
||||
.arg("upgrade")
|
||||
.status_checked()
|
||||
ctx.execute(sudo).arg(&waydroid).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_auto_cpufreq(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1115,11 +1061,7 @@ pub fn run_auto_cpufreq(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("auto-cpufreq");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(auto_cpu_freq)
|
||||
.arg("--update")
|
||||
.status_checked()
|
||||
ctx.execute(sudo).arg(auto_cpu_freq).arg("--update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_cinnamon_spices_updater(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1127,10 +1069,7 @@ pub fn run_cinnamon_spices_updater(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Cinnamon spices");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(cinnamon_spice_updater)
|
||||
.arg("--update-all")
|
||||
.status_checked()
|
||||
ctx.execute(cinnamon_spice_updater).arg("--update-all").status_checked()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -16,19 +16,12 @@ pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
|
||||
print_separator("MacPorts");
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["port", "selfupdate"])
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo).args(["port", "selfupdate"]).status_checked()?;
|
||||
ctx.execute(sudo)
|
||||
.args(["port", "-u", "upgrade", "outdated"])
|
||||
.status_checked()?;
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["port", "-N", "reclaim"])
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo).args(["port", "-N", "reclaim"]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -38,7 +31,7 @@ pub fn run_mas(ctx: &ExecutionContext) -> Result<()> {
|
||||
let mas = require("mas")?;
|
||||
print_separator(t!("macOS App Store"));
|
||||
|
||||
ctx.run_type().execute(mas).arg("upgrade").status_checked()
|
||||
ctx.execute(mas).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -59,7 +52,7 @@ pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute("softwareupdate");
|
||||
let mut command = ctx.execute("softwareupdate");
|
||||
command.args(["--install", "--all"]);
|
||||
|
||||
if should_ask {
|
||||
@@ -88,7 +81,7 @@ pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> {
|
||||
.arg(application.path())
|
||||
.output_checked_utf8();
|
||||
if probe.is_ok() {
|
||||
let mut command = ctx.run_type().execute(&sparkle);
|
||||
let mut command = ctx.execute(&sparkle);
|
||||
command.args(["bundle", "--check-immediately", "--application"]);
|
||||
command.arg(application.path());
|
||||
command.status_checked()?;
|
||||
@@ -103,12 +96,7 @@ pub fn update_xcodes(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let should_ask = !(ctx.config().yes(Step::Xcodes) || ctx.config().dry_run());
|
||||
|
||||
let releases = ctx
|
||||
.run_type()
|
||||
.execute(&xcodes)
|
||||
.args(["update"])
|
||||
.output_checked_utf8()?
|
||||
.stdout;
|
||||
let releases = ctx.execute(&xcodes).args(["update"]).output_checked_utf8()?.stdout;
|
||||
|
||||
let releases_installed: Vec<String> = releases
|
||||
.lines()
|
||||
@@ -165,12 +153,7 @@ pub fn update_xcodes(ctx: &ExecutionContext) -> Result<()> {
|
||||
process_xcodes_releases(releases_regular, should_ask, ctx)?;
|
||||
}
|
||||
|
||||
let releases_new = ctx
|
||||
.run_type()
|
||||
.execute(&xcodes)
|
||||
.args(["list"])
|
||||
.output_checked_utf8()?
|
||||
.stdout;
|
||||
let releases_new = ctx.execute(&xcodes).args(["list"]).output_checked_utf8()?.stdout;
|
||||
|
||||
let releases_gm_new_installed: HashSet<_> = releases_new
|
||||
.lines()
|
||||
@@ -200,7 +183,6 @@ pub fn update_xcodes(ctx: &ExecutionContext) -> Result<()> {
|
||||
prompt_yesno(t!("Would you like to move the former Xcode release to the trash?").as_ref())?;
|
||||
if answer_uninstall {
|
||||
let _ = ctx
|
||||
.run_type()
|
||||
.execute(&xcodes)
|
||||
.args([
|
||||
"uninstall",
|
||||
@@ -227,7 +209,6 @@ pub fn process_xcodes_releases(releases_filtered: Vec<String>, should_ask: bool,
|
||||
let answer_install = prompt_yesno(t!("Would you like to install it?").as_ref())?;
|
||||
if answer_install {
|
||||
let _ = ctx
|
||||
.run_type()
|
||||
.execute(xcodes)
|
||||
.args(["install", &releases_filtered.last().cloned().unwrap_or_default()])
|
||||
.status_checked();
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn upgrade_openbsd(ctx: &ExecutionContext) -> Result<()> {
|
||||
vec!["/usr/sbin/syspatch"]
|
||||
};
|
||||
|
||||
ctx.run_type().execute(sudo).args(&args).status_checked()
|
||||
ctx.execute(sudo).args(&args).status_checked()
|
||||
}
|
||||
|
||||
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -49,8 +49,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.args(["/usr/sbin/pkg_delete", "-ac"])
|
||||
.status_checked()?;
|
||||
}
|
||||
@@ -60,7 +59,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
args.push("-Dsnap");
|
||||
}
|
||||
|
||||
ctx.run_type().execute(sudo).args(&args).status_checked()?;
|
||||
ctx.execute(sudo).args(&args).status_checked()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ use crate::error::SkipStep;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use crate::executor::Executor;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use crate::executor::RunType;
|
||||
use crate::step::Step;
|
||||
use crate::terminal::print_separator;
|
||||
use crate::utils::{get_require_sudo_string, require, require_option, PathExt};
|
||||
@@ -75,19 +73,41 @@ impl BrewVariant {
|
||||
}
|
||||
}
|
||||
|
||||
fn execute(self, run_type: RunType) -> Executor {
|
||||
/// Execute an "internal" brew command, i.e. one that should always be run
|
||||
/// even when dry-running. Basically just a wrapper around [`Command::new`]
|
||||
/// that uses `arch` to run using the correct architecture if needed.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn execute_internal(self) -> Command {
|
||||
match self {
|
||||
BrewVariant::MacIntel if cfg!(target_arch = "aarch64") => {
|
||||
let mut command = run_type.execute("arch");
|
||||
let mut command = Command::new("arch");
|
||||
command.arg("-x86_64").arg(self.binary_name());
|
||||
command
|
||||
}
|
||||
BrewVariant::MacArm if cfg!(target_arch = "x86_64") => {
|
||||
let mut command = run_type.execute("arch");
|
||||
let mut command = Command::new("arch");
|
||||
command.arg("-arm64e").arg(self.binary_name());
|
||||
command
|
||||
}
|
||||
_ => run_type.execute(self.binary_name()),
|
||||
_ => Command::new(self.binary_name()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute a brew command. Uses `arch` to run using the correct
|
||||
/// architecture on macOS if needed.
|
||||
fn execute(self, ctx: &ExecutionContext) -> Executor {
|
||||
match self {
|
||||
BrewVariant::MacIntel if cfg!(target_arch = "aarch64") => {
|
||||
let mut command = ctx.execute("arch");
|
||||
command.arg("-x86_64").arg(self.binary_name());
|
||||
command
|
||||
}
|
||||
BrewVariant::MacArm if cfg!(target_arch = "x86_64") => {
|
||||
let mut command = ctx.execute("arch");
|
||||
command.arg("-arm64e").arg(self.binary_name());
|
||||
command
|
||||
}
|
||||
_ => ctx.execute(self.binary_name()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +141,6 @@ pub fn run_fisher(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Fisher");
|
||||
|
||||
let version_str = ctx
|
||||
.run_type()
|
||||
.execute(&fish)
|
||||
.args(["-c", "fisher --version"])
|
||||
.output_checked_utf8()?
|
||||
@@ -130,13 +149,10 @@ pub fn run_fisher(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if version_str.starts_with("fisher version 3.") {
|
||||
// v3 - see https://github.com/topgrade-rs/topgrade/pull/37#issuecomment-1283844506
|
||||
ctx.run_type().execute(&fish).args(["-c", "fisher"]).status_checked()
|
||||
ctx.execute(&fish).args(["-c", "fisher"]).status_checked()
|
||||
} else {
|
||||
// v4
|
||||
ctx.run_type()
|
||||
.execute(&fish)
|
||||
.args(["-c", "fisher update"])
|
||||
.status_checked()
|
||||
ctx.execute(&fish).args(["-c", "fisher update"]).status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +161,7 @@ pub fn run_bashit(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bash-it");
|
||||
|
||||
ctx.run_type()
|
||||
.execute("bash")
|
||||
ctx.execute("bash")
|
||||
.args(["-lic", &format!("bash-it update {}", ctx.config().bashit_branch())])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -169,7 +184,7 @@ pub fn run_oh_my_bash(ctx: &ExecutionContext) -> Result<()> {
|
||||
let mut update_script = oh_my_bash;
|
||||
update_script.push_str("/tools/upgrade.sh");
|
||||
|
||||
ctx.run_type().execute("bash").arg(update_script).status_checked()
|
||||
ctx.execute("bash").arg(update_script).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -178,7 +193,7 @@ pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("oh-my-fish");
|
||||
|
||||
ctx.run_type().execute(fish).args(["-c", "omf update"]).status_checked()
|
||||
ctx.execute(fish).args(["-c", "omf update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pkgin(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -187,14 +202,14 @@ pub fn run_pkgin(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Pkgin");
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(&pkgin).arg("update");
|
||||
if ctx.config().yes(Step::Pkgin) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(&pkgin).arg("upgrade");
|
||||
if ctx.config().yes(Step::Pkgin) {
|
||||
command.arg("-y");
|
||||
@@ -210,10 +225,7 @@ pub fn run_fish_plug(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("fish-plug");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(fish)
|
||||
.args(["-c", "plug update"])
|
||||
.status_checked()
|
||||
ctx.execute(fish).args(["-c", "plug update"]).status_checked()
|
||||
}
|
||||
|
||||
/// Upgrades `fundle` and `fundle` plugins.
|
||||
@@ -227,8 +239,7 @@ pub fn run_fundle(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("fundle");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(fish)
|
||||
ctx.execute(fish)
|
||||
.args(["-c", "fundle self-update && fundle update"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -260,8 +271,7 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("GNOME Shell extensions"));
|
||||
|
||||
ctx.run_type()
|
||||
.execute(gdbus)
|
||||
ctx.execute(gdbus)
|
||||
.args([
|
||||
"call",
|
||||
"--session",
|
||||
@@ -318,8 +328,7 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
||||
print_separator(format!("{} ({})", variant.step_title(), sudo_as_user));
|
||||
|
||||
let sudo = crate::utils::require_option(ctx.sudo().as_ref(), crate::utils::get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.current_dir("/tmp") // brew needs a writable current directory
|
||||
.args([
|
||||
"--set-home",
|
||||
@@ -332,11 +341,10 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
||||
}
|
||||
}
|
||||
print_separator(variant.step_title());
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
variant.execute(run_type).arg("update").status_checked()?;
|
||||
variant.execute(ctx).arg("update").status_checked()?;
|
||||
|
||||
let mut command = variant.execute(run_type);
|
||||
let mut command = variant.execute(ctx);
|
||||
command.args(["upgrade", "--formula"]);
|
||||
|
||||
if ctx.config().brew_fetch_head() {
|
||||
@@ -346,11 +354,11 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").status_checked()?;
|
||||
variant.execute(ctx).arg("cleanup").status_checked()?;
|
||||
}
|
||||
|
||||
if ctx.config().brew_autoremove() {
|
||||
variant.execute(run_type).arg("autoremove").status_checked()?;
|
||||
variant.execute(ctx).arg("autoremove").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -363,10 +371,9 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
|
||||
return Err(SkipStep(t!("Not a custom brew for macOS").to_string()).into());
|
||||
}
|
||||
print_separator(format!("{} - Cask", variant.step_title()));
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
let cask_upgrade_exists = variant
|
||||
.execute(RunType::Wet)
|
||||
.execute_internal()
|
||||
.args(["--repository", "buo/cask-upgrade"])
|
||||
.output_checked_utf8()
|
||||
.map(|p| Path::new(p.stdout.trim()).exists())?;
|
||||
@@ -391,10 +398,10 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
|
||||
}
|
||||
}
|
||||
|
||||
variant.execute(run_type).args(&brew_args).status_checked()?;
|
||||
variant.execute(ctx).args(&brew_args).status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").status_checked()?;
|
||||
variant.execute(ctx).arg("cleanup").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -403,8 +410,6 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
|
||||
pub fn run_guix(ctx: &ExecutionContext) -> Result<()> {
|
||||
let guix = require("guix")?;
|
||||
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
let output = Command::new(&guix).arg("pull").output_checked_utf8();
|
||||
debug!("guix pull output: {:?}", output);
|
||||
let should_upgrade = output.is_ok();
|
||||
@@ -413,7 +418,7 @@ pub fn run_guix(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Guix");
|
||||
|
||||
if should_upgrade {
|
||||
return run_type.execute(&guix).args(["package", "-u"]).status_checked();
|
||||
return ctx.execute(&guix).args(["package", "-u"]).status_checked();
|
||||
}
|
||||
Err(SkipStep(t!("Guix Pull Failed, Skipping").to_string()).into())
|
||||
}
|
||||
@@ -441,10 +446,9 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let run_type = ctx.run_type();
|
||||
run_type.execute(nix_channel).arg("--update").status_checked()?;
|
||||
ctx.execute(nix_channel).arg("--update").status_checked()?;
|
||||
|
||||
let mut get_version_cmd = ctx.run_type().execute(&nix);
|
||||
let mut get_version_cmd = ctx.execute(&nix);
|
||||
get_version_cmd.arg("--version");
|
||||
let get_version_cmd_output = get_version_cmd.output_checked_utf8()?;
|
||||
let get_version_cmd_first_line_stdout = get_version_cmd_output
|
||||
@@ -498,8 +502,7 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
};
|
||||
|
||||
if Path::new(&manifest_json_path).exists() {
|
||||
run_type
|
||||
.execute(nix)
|
||||
ctx.execute(nix)
|
||||
.args(nix_args())
|
||||
.arg("profile")
|
||||
.arg("upgrade")
|
||||
@@ -507,7 +510,7 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
.arg("--verbose")
|
||||
.status_checked()
|
||||
} else {
|
||||
let mut command = run_type.execute(nix_env);
|
||||
let mut command = ctx.execute(nix_env);
|
||||
command.arg("--upgrade");
|
||||
if let Some(args) = ctx.config().nix_env_arguments() {
|
||||
command.args(args.split_whitespace());
|
||||
@@ -553,11 +556,7 @@ pub fn run_nix_self_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
.arg("upgrade-nix")
|
||||
.status_checked()
|
||||
} else {
|
||||
ctx.run_type()
|
||||
.execute(&nix)
|
||||
.args(nix_args)
|
||||
.arg("upgrade-nix")
|
||||
.status_checked()
|
||||
ctx.execute(&nix).args(nix_args).arg("upgrade-nix").status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,8 +634,6 @@ fn flake_dir(var: &'static str) -> Option<PathBuf> {
|
||||
///
|
||||
/// See: https://github.com/viperML/nh
|
||||
pub fn run_nix_helper(ctx: &ExecutionContext) -> Result<()> {
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
require("nix")?;
|
||||
let nix_helper = require("nh")?;
|
||||
|
||||
@@ -669,7 +666,7 @@ pub fn run_nix_helper(ctx: &ExecutionContext) -> Result<()> {
|
||||
let nh_switch = |ty: &'static str| -> Result<()> {
|
||||
print_separator(format!("nh {ty}"));
|
||||
|
||||
let mut cmd = run_type.execute(&nix_helper);
|
||||
let mut cmd = ctx.execute(&nix_helper);
|
||||
cmd.arg(ty);
|
||||
cmd.arg("switch");
|
||||
cmd.arg("-u");
|
||||
@@ -712,7 +709,7 @@ pub fn run_yadm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("yadm");
|
||||
|
||||
ctx.run_type().execute(yadm).arg("pull").status_checked()
|
||||
ctx.execute(yadm).arg("pull").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_asdf(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -749,16 +746,10 @@ pub fn run_asdf(ctx: &ExecutionContext) -> Result<()> {
|
||||
let version =
|
||||
Version::parse(remaining).wrap_err_with(|| output_changed_message!("asdf version", "invalid version"))?;
|
||||
if version < Version::new(0, 15, 0) {
|
||||
ctx.run_type()
|
||||
.execute(&asdf)
|
||||
.arg("update")
|
||||
.status_checked_with_codes(&[42])?;
|
||||
ctx.execute(&asdf).arg("update").status_checked_with_codes(&[42])?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&asdf)
|
||||
.args(["plugin", "update", "--all"])
|
||||
.status_checked()
|
||||
ctx.execute(&asdf).args(["plugin", "update", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_mise(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -766,12 +757,9 @@ pub fn run_mise(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("mise");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&mise)
|
||||
.args(["plugins", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&mise).args(["plugins", "update"]).status_checked()?;
|
||||
|
||||
ctx.run_type().execute(&mise).arg("upgrade").status_checked()
|
||||
ctx.execute(&mise).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_home_manager(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -779,7 +767,7 @@ pub fn run_home_manager(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("home-manager");
|
||||
|
||||
let mut cmd = ctx.run_type().execute(home_manager);
|
||||
let mut cmd = ctx.execute(home_manager);
|
||||
cmd.arg("switch");
|
||||
|
||||
if let Some(extra_args) = ctx.config().home_manager() {
|
||||
@@ -793,14 +781,14 @@ pub fn run_tldr(ctx: &ExecutionContext) -> Result<()> {
|
||||
let tldr = require("tldr")?;
|
||||
|
||||
print_separator("TLDR");
|
||||
ctx.run_type().execute(tldr).arg("--update").status_checked()
|
||||
ctx.execute(tldr).arg("--update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pearl(ctx: &ExecutionContext) -> Result<()> {
|
||||
let pearl = require("pearl")?;
|
||||
print_separator("pearl");
|
||||
|
||||
ctx.run_type().execute(pearl).arg("update").status_checked()
|
||||
ctx.execute(pearl).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pyenv(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -821,7 +809,7 @@ pub fn run_pyenv(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep(t!("pyenv-update plugin is not installed").to_string()).into());
|
||||
}
|
||||
|
||||
ctx.run_type().execute(pyenv).arg("update").status_checked()
|
||||
ctx.execute(pyenv).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_sdkman(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -850,34 +838,25 @@ pub fn run_sdkman(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if selfupdate_enabled == "true" {
|
||||
let cmd_selfupdate = format!("source {} && sdk selfupdate", &sdkman_init_path);
|
||||
ctx.run_type()
|
||||
.execute(&bash)
|
||||
ctx.execute(&bash)
|
||||
.args(["-c", cmd_selfupdate.as_str()])
|
||||
.status_checked()?;
|
||||
}
|
||||
|
||||
let cmd_update = format!("source {} && sdk update", &sdkman_init_path);
|
||||
ctx.run_type()
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_update.as_str()])
|
||||
.status_checked()?;
|
||||
ctx.execute(&bash).args(["-c", cmd_update.as_str()]).status_checked()?;
|
||||
|
||||
let cmd_upgrade = format!("source {} && sdk upgrade", &sdkman_init_path);
|
||||
ctx.run_type()
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_upgrade.as_str()])
|
||||
.status_checked()?;
|
||||
ctx.execute(&bash).args(["-c", cmd_upgrade.as_str()]).status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let cmd_flush_archives = format!("source {} && sdk flush archives", &sdkman_init_path);
|
||||
ctx.run_type()
|
||||
.execute(&bash)
|
||||
ctx.execute(&bash)
|
||||
.args(["-c", cmd_flush_archives.as_str()])
|
||||
.status_checked()?;
|
||||
|
||||
let cmd_flush_temp = format!("source {} && sdk flush temp", &sdkman_init_path);
|
||||
ctx.run_type()
|
||||
.execute(&bash)
|
||||
ctx.execute(&bash)
|
||||
.args(["-c", cmd_flush_temp.as_str()])
|
||||
.status_checked()?;
|
||||
}
|
||||
@@ -898,7 +877,7 @@ pub fn run_bun_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
ctx.run_type().execute(bun).args(["-g", "update"]).status_checked()
|
||||
ctx.execute(bun).args(["-g", "update"]).status_checked()
|
||||
}
|
||||
|
||||
/// Update dotfiles with `rcm(7)`.
|
||||
@@ -908,14 +887,14 @@ pub fn run_rcm(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rcup = require("rcup")?;
|
||||
|
||||
print_separator("rcm");
|
||||
ctx.run_type().execute(rcup).arg("-v").status_checked()
|
||||
ctx.execute(rcup).arg("-v").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_maza(ctx: &ExecutionContext) -> Result<()> {
|
||||
let maza = require("maza")?;
|
||||
|
||||
print_separator("maza");
|
||||
ctx.run_type().execute(maza).arg("update").status_checked()
|
||||
ctx.execute(maza).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn reboot() -> Result<()> {
|
||||
|
||||
@@ -21,11 +21,11 @@ pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let mut command = match ctx.sudo() {
|
||||
Some(sudo) => {
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(choco);
|
||||
command
|
||||
}
|
||||
None => ctx.run_type().execute(choco),
|
||||
None => ctx.execute(choco),
|
||||
};
|
||||
|
||||
command.args(["upgrade", "all"]);
|
||||
@@ -42,22 +42,19 @@ pub fn run_winget(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("winget");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&winget)
|
||||
.args(["source", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&winget).args(["source", "update"]).status_checked()?;
|
||||
|
||||
let mut command = if ctx.config().winget_use_sudo() {
|
||||
match ctx.sudo() {
|
||||
Some(sudo) => {
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
let mut command = ctx.execute(sudo);
|
||||
command.arg(winget);
|
||||
command
|
||||
}
|
||||
None => ctx.run_type().execute(winget),
|
||||
None => ctx.execute(winget),
|
||||
}
|
||||
} else {
|
||||
ctx.run_type().execute(winget)
|
||||
ctx.execute(winget)
|
||||
};
|
||||
|
||||
let mut args = vec!["upgrade", "--all"];
|
||||
@@ -75,15 +72,12 @@ pub fn run_scoop(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Scoop");
|
||||
|
||||
ctx.run_type().execute(&scoop).args(["update"]).status_checked()?;
|
||||
ctx.run_type().execute(&scoop).args(["update", "*"]).status_checked()?;
|
||||
ctx.execute(&scoop).args(["update"]).status_checked()?;
|
||||
ctx.execute(&scoop).args(["update", "*"]).status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&scoop).args(["cleanup", "*"]).status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&scoop)
|
||||
.args(["cache", "rm", "-a"])
|
||||
.status_checked()?
|
||||
ctx.execute(&scoop).args(["cleanup", "*"]).status_checked()?;
|
||||
ctx.execute(&scoop).args(["cache", "rm", "-a"]).status_checked()?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -97,7 +91,7 @@ pub fn update_wsl(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Update WSL"));
|
||||
|
||||
let mut wsl_command = ctx.run_type().execute(wsl);
|
||||
let mut wsl_command = ctx.execute(wsl);
|
||||
wsl_command.args(["--update"]);
|
||||
|
||||
if ctx.config().wsl_update_pre_release() {
|
||||
@@ -153,7 +147,7 @@ fn upgrade_wsl_distribution(wsl: &Path, dist: &str, ctx: &ExecutionContext) -> R
|
||||
.trim_end()
|
||||
.to_owned();
|
||||
|
||||
let mut command = ctx.run_type().execute(wsl);
|
||||
let mut command = ctx.execute(wsl);
|
||||
|
||||
// The `arg` method automatically quotes its arguments.
|
||||
// This means we can't append additional arguments to `topgrade` in WSL
|
||||
|
||||
@@ -75,13 +75,12 @@ impl Powershell {
|
||||
/// Builds a "primary" powershell command (uses dry-run if required):
|
||||
/// {powershell} -NoProfile -Command {cmd}
|
||||
fn build_command<'a>(&self, ctx: &'a ExecutionContext, cmd: &str, use_sudo: bool) -> Result<impl CommandExt + 'a> {
|
||||
let executor = &mut ctx.run_type();
|
||||
let mut command = if use_sudo && ctx.sudo().is_some() {
|
||||
let mut cmd = executor.execute(ctx.sudo().as_ref().unwrap());
|
||||
let mut cmd = ctx.execute(ctx.sudo().as_ref().unwrap());
|
||||
cmd.arg(&self.path);
|
||||
cmd
|
||||
} else {
|
||||
executor.execute(&self.path)
|
||||
ctx.execute(&self.path)
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
|
||||
unreachable!("Tmux execution is only implemented in Unix");
|
||||
} else if ctx.config().open_remotes_in_new_terminal() && !ctx.run_type().dry() && cfg!(windows) {
|
||||
prepare_async_ssh_command(&mut args);
|
||||
ctx.run_type().execute("wt").args(&args).spawn()?;
|
||||
ctx.execute("wt").args(&args).spawn()?;
|
||||
Err(SkipStep(String::from(t!("Remote Topgrade launched in an external terminal"))).into())
|
||||
} else {
|
||||
let mut args = vec!["-t", hostname];
|
||||
@@ -50,6 +50,6 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
|
||||
print_separator(format!("Remote ({hostname})"));
|
||||
println!("{}", t!("Connecting to {hostname}...", hostname = hostname));
|
||||
|
||||
ctx.run_type().execute(ssh).args(&args).status_checked()
|
||||
ctx.execute(ssh).args(&args).status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,7 @@ impl<'a> TemporaryPowerOn<'a> {
|
||||
BoxStatus::Running => unreachable!(),
|
||||
};
|
||||
|
||||
ctx.run_type()
|
||||
.execute(vagrant)
|
||||
ctx.execute(vagrant)
|
||||
.args([subcommand, &vagrant_box.name])
|
||||
.current_dir(vagrant_box.path.clone())
|
||||
.status_checked()?;
|
||||
@@ -141,7 +140,6 @@ impl Drop for TemporaryPowerOn<'_> {
|
||||
|
||||
println!();
|
||||
self.ctx
|
||||
.run_type()
|
||||
.execute(self.vagrant)
|
||||
.args([subcommand, &self.vagrant_box.name])
|
||||
.current_dir(self.vagrant_box.path.clone())
|
||||
@@ -202,8 +200,7 @@ pub fn topgrade_vagrant_box(ctx: &ExecutionContext, vagrant_box: &VagrantBox) ->
|
||||
command.push_str(" -y");
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&vagrant.path)
|
||||
ctx.execute(&vagrant.path)
|
||||
.current_dir(&vagrant_box.path)
|
||||
.args(["ssh", "-c", &command])
|
||||
.status_checked()
|
||||
@@ -223,7 +220,6 @@ pub fn upgrade_vagrant_boxes(ctx: &ExecutionContext) -> Result<()> {
|
||||
for ele in re.captures_iter(&outdated.stdout) {
|
||||
found = true;
|
||||
let _ = ctx
|
||||
.run_type()
|
||||
.execute(&vagrant)
|
||||
.args(["box", "update", "--box"])
|
||||
.arg(ele.get(1).unwrap().as_str())
|
||||
@@ -235,10 +231,7 @@ pub fn upgrade_vagrant_boxes(ctx: &ExecutionContext) -> Result<()> {
|
||||
if !found {
|
||||
println!("{}", t!("No outdated boxes"));
|
||||
} else {
|
||||
ctx.run_type()
|
||||
.execute(&vagrant)
|
||||
.args(["box", "prune"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&vagrant).args(["box", "prune"]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -48,7 +48,7 @@ pub fn run_tpm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("tmux plugins");
|
||||
|
||||
ctx.run_type().execute(tpm).arg("all").status_checked()
|
||||
ctx.execute(tpm).arg("all").status_checked()
|
||||
}
|
||||
|
||||
struct Tmux {
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn run_toolbx(ctx: &ExecutionContext) -> Result<()> {
|
||||
args.push("--yes");
|
||||
}
|
||||
|
||||
ctx.run_type().execute(&toolbx).args(&args).status_checked()?;
|
||||
ctx.execute(&toolbx).args(&args).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -80,23 +80,19 @@ pub fn upgrade_ultimate_vimrc(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("The Ultimate vimrc"));
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&git)
|
||||
ctx.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["reset", "--hard"])
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&git)
|
||||
ctx.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["clean", "-d", "--force"])
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&git)
|
||||
ctx.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["pull", "--rebase"])
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(python)
|
||||
ctx.execute(python)
|
||||
.current_dir(config_dir)
|
||||
.arg(update_plugins)
|
||||
.status_checked()?;
|
||||
@@ -116,8 +112,7 @@ pub fn upgrade_vim(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Vim");
|
||||
upgrade(
|
||||
ctx.run_type()
|
||||
.execute(&vim)
|
||||
ctx.execute(&vim)
|
||||
.args(["-u"])
|
||||
.arg(vimrc)
|
||||
.args(["-U", "NONE", "-V1", "-nNesS"])
|
||||
@@ -132,8 +127,7 @@ pub fn upgrade_neovim(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Neovim");
|
||||
upgrade(
|
||||
ctx.run_type()
|
||||
.execute(nvim)
|
||||
ctx.execute(nvim)
|
||||
.args(["-u"])
|
||||
.arg(nvimrc)
|
||||
.args(["--headless", "-V1", "-nS"])
|
||||
@@ -147,5 +141,5 @@ pub fn run_voom(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("voom");
|
||||
|
||||
ctx.run_type().execute(voom).arg("update").status_checked()
|
||||
ctx.execute(voom).arg("update").status_checked()
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@ pub fn run_zr(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("zr");
|
||||
|
||||
let cmd = format!("source {} && zr --update", zshrc().display());
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
.args(["-l", "-c", cmd.as_str()])
|
||||
.status_checked()
|
||||
ctx.execute(zsh).args(["-l", "-c", cmd.as_str()]).status_checked()
|
||||
}
|
||||
|
||||
fn zdotdir() -> PathBuf {
|
||||
@@ -44,8 +41,7 @@ pub fn run_antidote(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("antidote");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
ctx.execute(zsh)
|
||||
.arg("-c")
|
||||
.arg(format!("source {} && antidote update", antidote.display()))
|
||||
.status_checked()
|
||||
@@ -57,7 +53,7 @@ pub fn run_antibody(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("antibody");
|
||||
|
||||
ctx.run_type().execute(antibody).arg("update").status_checked()
|
||||
ctx.execute(antibody).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_antigen(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -70,10 +66,7 @@ pub fn run_antigen(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("antigen");
|
||||
|
||||
let cmd = format!("source {} && (antigen selfupdate ; antigen update)", zshrc.display());
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
.args(["-l", "-c", cmd.as_str()])
|
||||
.status_checked()
|
||||
ctx.execute(zsh).args(["-l", "-c", cmd.as_str()]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zgenom(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -86,10 +79,7 @@ pub fn run_zgenom(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("zgenom");
|
||||
|
||||
let cmd = format!("source {} && zgenom selfupdate && zgenom update", zshrc.display());
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
.args(["-l", "-c", cmd.as_str()])
|
||||
.status_checked()
|
||||
ctx.execute(zsh).args(["-l", "-c", cmd.as_str()]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zplug(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -102,10 +92,7 @@ pub fn run_zplug(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("zplug");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
.args(["-i", "-c", "zplug update"])
|
||||
.status_checked()
|
||||
ctx.execute(zsh).args(["-i", "-c", "zplug update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zinit(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -119,10 +106,7 @@ pub fn run_zinit(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("zinit");
|
||||
|
||||
let cmd = format!("source {} && zinit self-update && zinit update --all", zshrc.display());
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
.args(["-i", "-c", cmd.as_str()])
|
||||
.status_checked()
|
||||
ctx.execute(zsh).args(["-i", "-c", cmd.as_str()]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zi(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -134,7 +118,7 @@ pub fn run_zi(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("zi");
|
||||
|
||||
let cmd = format!("source {} && zi self-update && zi update --all", zshrc.display());
|
||||
ctx.run_type().execute(zsh).args(["-i", "-c", &cmd]).status_checked()
|
||||
ctx.execute(zsh).args(["-i", "-c", &cmd]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zim(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -152,8 +136,7 @@ pub fn run_zim(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("zim");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(zsh)
|
||||
ctx.execute(zsh)
|
||||
.args(["-i", "-c", "zimfw upgrade && zimfw update"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -219,8 +202,7 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
custom_repos.remove(&oh_my_zsh);
|
||||
ctx.run_type()
|
||||
.execute("zsh")
|
||||
ctx.execute("zsh")
|
||||
.arg(oh_my_zsh.join("tools/upgrade.sh"))
|
||||
// oh-my-zsh returns 80 when it is already updated and no changes pulled
|
||||
// in this update.
|
||||
|
||||
@@ -61,7 +61,7 @@ impl Sudo {
|
||||
/// See: https://github.com/topgrade-rs/topgrade/issues/205
|
||||
pub fn elevate(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Sudo");
|
||||
let mut cmd = ctx.run_type().execute(self);
|
||||
let mut cmd = ctx.execute(&self.path);
|
||||
match self.kind {
|
||||
SudoKind::Doas => {
|
||||
// `doas` doesn't have anything like `sudo -v` to cache credentials,
|
||||
@@ -115,7 +115,7 @@ impl Sudo {
|
||||
|
||||
/// Execute a command with `sudo`.
|
||||
pub fn execute_elevated(&self, ctx: &ExecutionContext, command: &Path, interactive: bool) -> Executor {
|
||||
let mut cmd = ctx.run_type().execute(self);
|
||||
let mut cmd = ctx.execute(&self.path);
|
||||
|
||||
if let SudoKind::Sudo = self.kind {
|
||||
cmd.arg("--preserve-env=DIFFPROG");
|
||||
|
||||
Reference in New Issue
Block a user