Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Add a flag for skipping system upgrades (fixes #53)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Aug 13, 2018
1 parent b9e9fad commit ab1e480
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ fn run() -> Result<(), Error> {
.short("t")
.long("tmux"),
)
.arg(
Arg::with_name("no_system")
.help("Don't perform system upgrade")
.long("no-system"),
)
.get_matches();

if matches.is_present("tmux") && env::var("TMUX").is_err() {
Expand Down Expand Up @@ -91,37 +96,39 @@ fn run() -> Result<(), Error> {
}
}

#[cfg(target_os = "linux")]
{
terminal.print_separator("System update");
match linux::Distribution::detect() {
Ok(distribution) => {
match distribution {
linux::Distribution::Arch => linux::upgrade_arch_linux(&sudo, &mut terminal),
linux::Distribution::CentOS => linux::upgrade_redhat(&sudo, &mut terminal),
linux::Distribution::Fedora => linux::upgrade_fedora(&sudo, &mut terminal),
linux::Distribution::Ubuntu | linux::Distribution::Debian => {
linux::upgrade_debian(&sudo, &mut terminal)
}
}.report("System upgrade", &mut reports);
}

Err(e) => {
println!("Error detecting current distribution: {}", e);
if !(matches.is_present("no_system")) {
#[cfg(target_os = "linux")]
{
terminal.print_separator("System update");
match linux::Distribution::detect() {
Ok(distribution) => {
match distribution {
linux::Distribution::Arch => linux::upgrade_arch_linux(&sudo, &mut terminal),
linux::Distribution::CentOS => linux::upgrade_redhat(&sudo, &mut terminal),
linux::Distribution::Fedora => linux::upgrade_fedora(&sudo, &mut terminal),
linux::Distribution::Ubuntu | linux::Distribution::Debian => {
linux::upgrade_debian(&sudo, &mut terminal)
}
}.report("System upgrade", &mut reports);
}

Err(e) => {
println!("Error detecting current distribution: {}", e);
}
}
}
}

if let Some(brew) = utils::which("brew") {
terminal.print_separator("Brew");
run_homebrew(&brew).report("Brew", &mut reports);
}
if let Some(brew) = utils::which("brew") {
terminal.print_separator("Brew");
run_homebrew(&brew).report("Brew", &mut reports);
}

#[cfg(windows)]
{
if let Some(choco) = utils::which("choco") {
terminal.print_separator("Chocolatey");
windows::run_chocolatey(&choco).report("Chocolatey", &mut reports);
#[cfg(windows)]
{
if let Some(choco) = utils::which("choco") {
terminal.print_separator("Chocolatey");
windows::run_chocolatey(&choco).report("Chocolatey", &mut reports);
}
}
}

Expand Down Expand Up @@ -263,8 +270,10 @@ fn run() -> Result<(), Error> {

#[cfg(target_os = "macos")]
{
terminal.print_separator("App Store");
macos::upgrade_macos().report("App Store", &mut reports);
if !(matches.is_present("no_system")) {
terminal.print_separator("App Store");
macos::upgrade_macos().report("App Store", &mut reports);
}
}

if !reports.is_empty() {
Expand Down

0 comments on commit ab1e480

Please sign in to comment.