Skip to content

Commit

Permalink
updated main for additional installs
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaverly committed Jan 18, 2023
1 parent 2ca563b commit df75da2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use docker::DockerCommand;
use notes::NotesCommand;
use ssh::SSHCommand;
use std::process::exit;
use std::str;
use tasks::TasksCommand;
use std::process::{Stdio,Command};

#[derive(Debug, Parser)] // requires `derive` feature
#[command(name = "peaches")]
Expand Down Expand Up @@ -51,6 +53,9 @@ enum Commands {

/// Healthcheck
Healthcheck {},

/// Upgrade peaches
Upgrade {},
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -185,5 +190,29 @@ fn main() {
TasksCommand::healthcheck(true);
println!("\nPlease install all missing requirements from the above.");
}

Commands::Upgrade {} => {
println!("Getting new install script from peaches repository.\n");
let get_script = Command::new("wget")
.args(vec![
"https://raw.githubusercontent.com/KCaverly/peaches/main/install.sh",
"-O",
"-",
])
.stdout(Stdio::piped())
.spawn()
.unwrap();

println!("Installing new version of peaches\n");

let install_script = Command::new("sh")
.stdin(Stdio::from(get_script.stdout.unwrap()))
.spawn()
.unwrap();

let output = install_script.wait_with_output().unwrap();
let result = str::from_utf8(&output.stdout).unwrap();
println!("{}", result);
}
}
}

0 comments on commit df75da2

Please sign in to comment.