From 28c4c743eafad01219e916414fac035ee35affc8 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Wed, 24 Jun 2020 14:30:24 +0300 Subject: [PATCH] Split package managers to different steps (#447) --- src/config.rs | 12 +++++++++++- src/main.rs | 35 ++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 95a175d1..183ca603 100644 --- a/src/config.rs +++ b/src/config.rs @@ -61,7 +61,6 @@ type Commands = BTreeMap; #[strum(serialize_all = "snake_case")] pub enum Step { System, - PackageManagers, GitRepos, Vim, Emacs, @@ -90,6 +89,17 @@ pub enum Step { Wsl, Tmux, Vagrant, + MicrosoftAutoUpdate, + Brew, + MacPorts, + Nix, + HomeManager, + Asdf, + Chocolatey, + Scoop, + Flatpak, + Snap, + Pkg, } #[derive(Deserialize, Default, Debug)] diff --git a/src/main.rs b/src/main.rs index 67fa3b70..018e904a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,30 +133,45 @@ fn run() -> Result<()> { #[cfg(windows)] { - if config.should_run(Step::PackageManagers) { + if config.should_run(Step::Chocolatey) { runner.execute("Chocolatey", || windows::run_chocolatey(run_type))?; + } + if config.should_run(Step::Scoop) { runner.execute("Scoop", || windows::run_scoop(config.cleanup(), run_type))?; } } #[cfg(unix)] { - if config.should_run(Step::PackageManagers) { - #[cfg(target_os = "macos")] - runner.execute("Microsoft AutoUpdate", || macos::run_msupdate(&ctx))?; + if config.should_run(Step::Brew) { runner.execute("brew", || unix::run_homebrew(&ctx))?; - #[cfg(target_os = "macos")] - runner.execute("MacPorts", || macos::run_macports(&ctx))?; + } + #[cfg(target_os = "macos")] + { + if config.should_run(Step::MacPorts) { + runner.execute("MacPorts", || macos::run_macports(&ctx))?; + } + if config.should_run(Step::MicrosoftAutoUpdate) { + runner.execute("Microsoft AutoUpdate", || macos::run_msupdate(&ctx))?; + } + } + if config.should_run(Step::Nix) { runner.execute("nix", || unix::run_nix(&ctx))?; + } + + if config.should_run(Step::HomeManager) { runner.execute("home-manager", || unix::run_home_manager(run_type))?; + } + + if config.should_run(Step::Asdf) { runner.execute("asdf", || unix::run_asdf(run_type))?; } } #[cfg(target_os = "dragonfly")] { - if config.should_run(Step::PackageManagers) { + if config.should_run(Step::Pkg) { runner.execute("DragonFly BSD Packages", || { dragonfly::upgrade_packages(sudo.as_ref(), run_type) })?; @@ -165,7 +180,7 @@ fn run() -> Result<()> { #[cfg(target_os = "freebsd")] { - if config.should_run(Step::PackageManagers) { + if config.should_run(Step::Pkg) { runner.execute("FreeBSD Packages", || { freebsd::upgrade_packages(sudo.as_ref(), run_type) })?; @@ -335,8 +350,10 @@ fn run() -> Result<()> { #[cfg(target_os = "linux")] { - if config.should_run(Step::PackageManagers) { + if config.should_run(Step::Flatpak) { runner.execute("Flatpak", || linux::flatpak_update(run_type))?; + } + if config.should_run(Step::Snap) { runner.execute("snap", || linux::run_snap(sudo.as_ref(), run_type))?; } }