Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Commands:
-Su Upgrade system
-Syu Sync databases and upgrade system
--yay Full system + AUR upgrade via yay
--paru Full system + AUR upgrade via paru

Options:
--ascii <ASCII> Use custom ASCII art (path, built-in name, or NONE)
Expand Down Expand Up @@ -70,10 +71,13 @@ struct Cli {

#[arg(long = "yay", hide = true)]
yay: bool,

#[arg(long = "paru", hide = true)]
paru: bool,
}

fn is_bare_invocation(cli: &Cli) -> bool {
!cli.sync_op && !cli.sync_db && !cli.upgrade && !cli.yay && !cli.local
!cli.sync_op && !cli.sync_db && !cli.upgrade && !cli.yay && !cli.paru && !cli.local
}

fn print_error_and_help(msg: &str) -> ! {
Expand Down Expand Up @@ -161,6 +165,15 @@ fn main() {
std::process::exit(0);
}

// Handle --paru (full system + AUR upgrade via paru)
if cli.paru {
if let Err(e) = pacman::paru_upgrade(cli.debug, &config) {
eprintln!("error: {}", e);
std::process::exit(1);
}
std::process::exit(0);
}

// Skip fresh sync if: --local flag, or after -Sy
let fresh_sync = !(cli.local || cli.sync_op && cli.sync_db);

Expand Down
34 changes: 34 additions & 0 deletions src/pacman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,40 @@ pub fn yay_upgrade(debug: bool, config: &crate::config::Config) -> Result<(), St
Err(std::process::Command::new("yay").exec().to_string())
}

pub fn paru_upgrade(debug: bool, config: &crate::config::Config) -> Result<(), String> {
if !matches!(Command::new("paru").arg("--version").output(), Ok(o) if o.status.success()) {
return Err("paru is not installed.".to_string());
}

// Sync temp databases
let spinner = if debug {
None
} else {
Some(util::create_spinner("Gathering stats"))
};
let stat_ids = config.display.parsed_stats();
let mut stats = get_stats(&stat_ids, debug, true, config, spinner.as_ref());
let aur_count = get_aur_upgradable_count();
if let Some(ref s) = spinner {
s.finish_and_clear();
}

stats.total_upgradable += aur_count;

if debug {
crate::ui::display_stats(&stats, config);
println!();
} else if let Err(e) = crate::ui::display_stats_with_graphics(&stats, config) {
eprintln!("error: {}", e);
crate::ui::display_stats(&stats, config);
println!();
}

//hand off to paru
use std::os::unix::process::CommandExt;
Err(std::process::Command::new("paru").exec().to_string())
}

pub fn upgrade_system(
debug: bool,
sync_first: bool,
Expand Down