1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! Detection of AUR helpers and privilege escalation tools on the system.
use crate;
use command_on_path;
/// What: Detect the preferred AUR helper available on `PATH`.
///
/// Inputs: None.
///
/// Output:
/// - `Some(AurHelper::Paru)` when `paru` is available.
/// - `Some(AurHelper::Yay)` when only `yay` is available.
/// - `None` when neither helper is installed.
///
/// Details:
/// - Preference order (paru first, yay fallback) matches Pacsea's install flow.
/// - Detection is explicit: command builders never call this implicitly, so
/// callers can override the choice (e.g., from user configuration).
///
/// # Example
///
/// ```no_run
/// use arch_toolkit::install::detect_aur_helper;
///
/// match detect_aur_helper() {
/// Some(helper) => println!("Using AUR helper: {helper}"),
/// None => eprintln!("No AUR helper (paru/yay) found."),
/// }
/// ```
/// What: Detect the preferred privilege escalation tool available on `PATH`.
///
/// Inputs: None.
///
/// Output:
/// - `Some(PrivilegeTool::Doas)` when `doas` is available.
/// - `Some(PrivilegeTool::Sudo)` when only `sudo` is available.
/// - `None` when neither tool is installed.
///
/// Details:
/// - Preference order (doas first, sudo fallback) matches Pacsea's `Auto`
/// privilege mode: sudo is present on most systems by default, so an
/// installed doas signals a deliberate user choice.
/// - Callers with an explicit user configuration should honor it via
/// [`is_privilege_tool_available`] instead of calling this.
/// - Password handling is intentionally out of scope for arch-toolkit.
///
/// # Example
///
/// ```no_run
/// use arch_toolkit::install::detect_privilege_tool;
///
/// match detect_privilege_tool() {
/// Some(tool) => println!("Privilege tool: {tool}"),
/// None => eprintln!("No privilege tool (sudo/doas) found."),
/// }
/// ```
/// What: Check whether a specific AUR helper is available on `PATH`.
///
/// Inputs:
/// - `helper`: The helper to check.
///
/// Output:
/// - `true` when the helper binary is executable on `PATH`.
///
/// Details:
/// - Useful when the caller has a configured preference and wants to verify it.
/// What: Check whether a specific privilege tool is available on `PATH`.
///
/// Inputs:
/// - `tool`: The tool to check.
///
/// Output:
/// - `true` when the tool binary is executable on `PATH`.
///
/// Details:
/// - Useful when the caller has a configured preference and wants to verify it.