zoi_cli/cmd/autoremove.rs
1//! Command for removing unused packages (orphans).
2
3use anyhow::Result;
4use colored::Colorize;
5
6use crate::pkg;
7
8/// Runs the autoremove command.
9///
10/// # Errors
11///
12/// Returns an error if the autoremove operation fails.
13///
14/// # Panics
15///
16/// This function does not explicitly panic.
17pub fn run(yes: bool, dry_run: bool) -> Result<()> {
18 if dry_run {
19 println!(
20 "{} Autoremoving unused packages (Dry-run)...",
21 "::".bold().yellow()
22 );
23 } else {
24 println!("{} Autoremoving unused packages...", "::".bold().blue());
25 }
26
27 pkg::autoremove::run(yes, dry_run)?;
28
29 if !dry_run {
30 println!("\n{}", "Cleanup complete.".green());
31 }
32 Ok(())
33}