Merge pull request #38 from edera-dev/feat/partial-match-default

feat(entries): support '*' suffix as a partial match to an entry
This commit is contained in:
2025-11-15 21:25:59 -08:00
committed by GitHub
2 changed files with 11 additions and 2 deletions

View File

@@ -93,7 +93,17 @@ impl BootableEntry {
} }
/// Determine if this entry matches `needle` by comparing to the name or title of the entry. /// Determine if this entry matches `needle` by comparing to the name or title of the entry.
/// If `needle` ends with *, we will match a partial match.
pub fn is_match(&self, needle: &str) -> bool { pub fn is_match(&self, needle: &str) -> bool {
// If the needle ends with '*', we will accept a partial match.
if needle.ends_with("*") {
// Strip off any '*' at the end.
let partial = needle.trim_end_matches("*");
// Check if the name or title start with the partial match.
return self.name.starts_with(partial) || self.title.starts_with(partial);
}
// Standard quality matching rules.
self.name == needle || self.title == needle self.name == needle || self.title == needle
} }

View File

@@ -78,8 +78,7 @@ pub struct RootConfiguration {
/// Options configuration for Sprout, used when the corresponding options are not specified. /// Options configuration for Sprout, used when the corresponding options are not specified.
#[derive(Serialize, Deserialize, Debug, Default, Clone)] #[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct OptionsConfiguration { pub struct OptionsConfiguration {
/// The entry to boot without showing the boot menu. /// The entry to mark as the default entry, instead of the first entry.
/// If not specified, a boot menu is shown.
#[serde(rename = "default-entry", default)] #[serde(rename = "default-entry", default)]
pub default_entry: Option<String>, pub default_entry: Option<String>,
/// The timeout of the boot menu. /// The timeout of the boot menu.