pub fn build_pacman_install<S: AsRef<str>>(
names: &[S],
options: &InstallOptions,
) -> Result<CommandSpec>Expand description
What: Build a pacman install command for official repository packages.
Inputs:
names: Package names to install (validated against the safe-name allowlist).options: Flag options (needed,noconfirm;aur_onlyis ignored).
Output:
Ok(CommandSpec)likepacman -S --needed --noconfirm -- <names...>.
Details:
- Does NOT prefix a privilege tool; use
with_privilegefor that. - Omit
--needed(setoptions.needed = false) for explicit reinstalls, mirroring Pacsea’s reinstall path. - A
--operand terminator separates flags from package names so pacman can never reinterpret an operand as an option (defense in depth on top of name validation).
§Errors
Returns ArchToolkitError::InvalidPackageName when a name fails validation,
or ArchToolkitError::EmptyInput when names is empty.
§Example
use arch_toolkit::install::build_pacman_install;
use arch_toolkit::types::install::InstallOptions;
let spec = build_pacman_install(&["ripgrep", "fd"], &InstallOptions::default())?;
assert_eq!(spec.to_shell_string(), "pacman -S --needed --noconfirm -- ripgrep fd");