mirror of
https://github.com/eRgo35/ah.git
synced 2026-02-04 05:16:09 +01:00
0.3.0 upgrade now handled by topgrade
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4,7 +4,7 @@ version = 3
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ah"
|
name = "ah"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ah"
|
name = "ah"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
authors = ["Michał Czyż <mike@c2yz.com>"]
|
authors = ["Michał Czyż <mike@c2yz.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ pub fn read_packages(path: PathBuf) -> Vec<String> {
|
|||||||
|
|
||||||
pub fn append_package(path: PathBuf, package: &str) {
|
pub fn append_package(path: PathBuf, package: &str) {
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.write(true)
|
|
||||||
.append(true)
|
.append(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.expect("Failed to open file");
|
.expect("Failed to open file");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ fn main() {
|
|||||||
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
|
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
|
||||||
Some(cli::Commands::Find(Query { query })) => packages::find(query),
|
Some(cli::Commands::Find(Query { query })) => packages::find(query),
|
||||||
Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
|
Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
|
||||||
None => packages::upgrade(true),
|
None => packages::full_upgrade(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
|
|||||||
32
src/packages/full_upgrade.rs
Normal file
32
src/packages/full_upgrade.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
use colored::Colorize;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::packages::{ask_confirmation, SYSTEM_UPDATER};
|
||||||
|
|
||||||
|
pub fn full_upgrade(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
println!(
|
||||||
|
"{} {}",
|
||||||
|
"::".bold().green(),
|
||||||
|
"Initializing full system update...".bold()
|
||||||
|
);
|
||||||
|
|
||||||
|
if !ask_confirmation()? {
|
||||||
|
return Err("Operation aborted".into());
|
||||||
|
}
|
||||||
|
|
||||||
|
let noconfirm = if noconfirm { "-y" } else { "" };
|
||||||
|
|
||||||
|
let mut child = Command::new(SYSTEM_UPDATER)
|
||||||
|
.arg(noconfirm)
|
||||||
|
.spawn()
|
||||||
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
|
let status = child.wait().expect("Failed to wait on child");
|
||||||
|
|
||||||
|
if !status.success() {
|
||||||
|
return Err("System upgrade failed".into());
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{} {}", "::".bold().green(), "System upgraded".bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
pub mod choose_install;
|
pub mod choose_install;
|
||||||
pub mod find;
|
pub mod find;
|
||||||
|
pub mod full_upgrade;
|
||||||
pub mod install;
|
pub mod install;
|
||||||
pub mod rebuild;
|
pub mod rebuild;
|
||||||
pub mod remove;
|
pub mod remove;
|
||||||
@@ -12,12 +13,14 @@ pub mod upgrade;
|
|||||||
|
|
||||||
pub use choose_install::choose_install;
|
pub use choose_install::choose_install;
|
||||||
pub use find::find;
|
pub use find::find;
|
||||||
|
pub use full_upgrade::full_upgrade;
|
||||||
pub use install::install;
|
pub use install::install;
|
||||||
pub use rebuild::rebuild;
|
pub use rebuild::rebuild;
|
||||||
pub use remove::remove;
|
pub use remove::remove;
|
||||||
pub use sync::sync;
|
pub use sync::sync;
|
||||||
pub use upgrade::upgrade;
|
pub use upgrade::upgrade;
|
||||||
|
|
||||||
|
const SYSTEM_UPDATER: &str = "topgrade";
|
||||||
const PACKAGE_MANAGER: &str = "paru";
|
const PACKAGE_MANAGER: &str = "paru";
|
||||||
|
|
||||||
fn get_package_path() -> PathBuf {
|
fn get_package_path() -> PathBuf {
|
||||||
@@ -27,11 +30,7 @@ fn get_package_path() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ask_confirmation() -> Result<bool, io::Error> {
|
fn ask_confirmation() -> Result<bool, io::Error> {
|
||||||
print!(
|
print!("{} Do you want to continue? [Y/n] ", "::".bold().blue());
|
||||||
"{} {}",
|
|
||||||
"::".bold().blue(),
|
|
||||||
"Do you want to continue? [Y/n] "
|
|
||||||
);
|
|
||||||
io::stdout().flush()?;
|
io::stdout().flush()?;
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user