feat(boot): implement basic boot menu

This commit is contained in:
2025-10-26 23:59:50 -04:00
parent 9d2e25183b
commit 4bbac3e4d5
12 changed files with 304 additions and 32 deletions

View File

@@ -15,6 +15,10 @@ pub struct SproutOptions {
pub config: String,
/// Entry to boot without showing the boot menu.
pub boot: Option<String>,
/// Force display of the boot menu.
pub force_menu: bool,
/// The timeout for the boot menu in seconds.
pub menu_timeout: Option<u64>,
}
/// The default Sprout options.
@@ -23,6 +27,8 @@ impl Default for SproutOptions {
Self {
config: DEFAULT_CONFIG_PATH.to_string(),
boot: None,
force_menu: false,
menu_timeout: None,
}
}
}
@@ -49,6 +55,20 @@ impl OptionsRepresentable for SproutOptions {
form: OptionForm::Value,
},
),
(
"force-menu",
OptionDescription {
description: "Force showing of the boot menu",
form: OptionForm::Flag,
},
),
(
"menu-timeout",
OptionDescription {
description: "Boot menu timeout, in seconds",
form: OptionForm::Value,
},
),
(
"help",
OptionDescription {
@@ -76,6 +96,20 @@ impl OptionsRepresentable for SproutOptions {
result.boot = Some(value.context("--boot option requires a value")?);
}
"force-menu" => {
// Force showing of the boot menu.
result.force_menu = true;
}
"menu-timeout" => {
// The timeout for the boot menu in seconds.
let value = value.context("--menu-timeout option requires a value")?;
let value = value
.parse::<u64>()
.context("menu-timeout must be a number")?;
result.menu_timeout = Some(value);
}
_ => bail!("unknown option: --{key}"),
}
}