Files
topgrade/src/steps/os/windows.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

2019-02-11 20:38:51 +02:00
use crate::error::{Error, ErrorKind};
2019-01-01 22:22:07 +02:00
use crate::executor::{CommandExt, RunType};
2019-08-14 21:36:57 +03:00
use crate::terminal::print_separator;
use crate::utils::require;
2018-06-28 12:16:54 +03:00
use std::process::Command;
2019-02-11 20:38:51 +02:00
pub fn run_chocolatey(run_type: RunType) -> Result<(), Error> {
let choco = require("choco")?;
2018-06-28 12:16:54 +03:00
2019-02-11 20:38:51 +02:00
print_separator("Chocolatey");
run_type.execute(&choco).args(&["upgrade", "all"]).check_run()
2018-06-28 12:16:54 +03:00
}
2018-08-22 22:01:06 +03:00
2019-02-11 20:38:51 +02:00
pub fn run_scoop(run_type: RunType) -> Result<(), Error> {
let scoop = require("scoop")?;
2018-10-17 13:57:30 +03:00
2019-02-11 20:38:51 +02:00
print_separator("Scoop");
2018-10-17 13:57:30 +03:00
2019-02-11 20:38:51 +02:00
run_type.execute(&scoop).args(&["update"]).check_run()?;
run_type.execute(&scoop).args(&["update", "*"]).check_run()
2018-10-17 13:57:30 +03:00
}
pub fn run_wsl_topgrade(run_type: RunType) -> Result<(), Error> {
let wsl = require("wsl")?;
let topgrade = Command::new(&wsl)
.args(&["bash", "-l", "which", "topgrade"])
.check_output()
.map_err(|_| ErrorKind::SkipStep)?;
run_type
.execute(&wsl)
.args(&["bash", "-c"])
.arg(format!("TOPGRADE_PREFIX=WSL exec {}", topgrade))
.check_run()
}
2019-06-13 22:05:18 +03:00
pub fn reboot() {
Command::new("shutdown").args(&["/R", "/T", "0"]).spawn().ok();
}