chore: prioritize module suggestions

This commit is contained in:
iff 2025-01-03 15:25:18 +01:00
parent 65213efb3b
commit d044164f26
2 changed files with 13 additions and 13 deletions

View file

@ -21,18 +21,6 @@ pub fn suggest_candidates(data: &mut Data) {
let modules = &data.modules;
let fallbacks = &data.fallbacks;
if privilege.is_none() {
if let Some(candidates) = match_pattern("_PR_privilege", data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
}
if let Some(candidates) = match_pattern(executable, data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
if let Some(candidates) = match_pattern("_PR_general", data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
#[cfg(debug_assertions)]
{
eprintln!("modules: {modules:?}");
@ -47,6 +35,18 @@ pub fn suggest_candidates(data: &mut Data) {
}
}
if privilege.is_none() {
if let Some(candidates) = match_pattern("_PR_privilege", data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
}
if let Some(candidates) = match_pattern(executable, data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
if let Some(candidates) = match_pattern("_PR_general", data) {
add_candidates_no_dup(command, &mut suggest_candidates, &candidates);
}
if !suggest_candidates.is_empty() {
data.candidates = suggest_candidates;
return;

View file

@ -22,7 +22,7 @@ There are 2 types of modules:
- **CAUTION**: Will immediately return if a suggestion is obtained
- Naming convention: `_pay-respects-fallback-<priority>-<your module name>`
Priority is used to retrieve suggestions in a specific order by an [unstable sort](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable) (although they will always be after compile-time matches). Default modules have a priority of `100`.
Priority is used to retrieve suggestions in a specific order by an [unstable sort](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable). Default modules have a priority of `100`.
When running your module, you will get the following environment variables: