pub fn with_privilege(tool: PrivilegeTool, spec: CommandSpec) -> CommandSpecExpand description
What: Wrap a command with a privilege escalation tool prefix.
Inputs:
tool: The privilege tool (sudoordoas).spec: The command to wrap.
Output:
- New
CommandSpeclikesudo pacman -S ....
Details:
- Pure transformation: the original program becomes the first argument.
- Do NOT wrap AUR helper commands; helpers escalate internally.
- Password handling (stdin piping, askpass) is intentionally out of scope.
ยงExample
use arch_toolkit::install::{build_update_command, with_privilege};
use arch_toolkit::types::install::PrivilegeTool;
let spec = with_privilege(PrivilegeTool::Sudo, build_update_command(None, true));
assert_eq!(spec.to_shell_string(), "sudo pacman -Syu --noconfirm");