Skip to main content

build_remove_command

Function build_remove_command 

Source
pub fn build_remove_command<S: AsRef<str>>(
    names: &[S],
    cascade: CascadeMode,
    noconfirm: bool,
) -> Result<CommandSpec>
Expand description

What: Build a pacman remove command with the requested cascade level.

Inputs:

  • names: Package names to remove (validated).
  • cascade: Cascade level (-R, -Rs, or -Rns).
  • noconfirm: Pass --noconfirm for non-interactive removal.

Output:

  • Ok(CommandSpec) like pacman -Rns --noconfirm -- <names...>.

Details:

  • Does NOT prefix a privilege tool; use with_privilege for that.
  • Cascade semantics ported from Pacsea’s CascadeMode.
  • A -- operand terminator separates flags from package names.

§Errors

Returns ArchToolkitError::InvalidPackageName when a name fails validation, or ArchToolkitError::EmptyInput when names is empty.

§Example

use arch_toolkit::install::build_remove_command;
use arch_toolkit::types::install::CascadeMode;

let spec = build_remove_command(&["ripgrep"], CascadeMode::CascadeWithConfigs, true)?;
assert_eq!(spec.to_shell_string(), "pacman -Rns --noconfirm -- ripgrep");