feat(config): rename [defaults] to [options]

This commit is contained in:
2025-10-27 17:56:38 -04:00
parent 26315fb4c4
commit 3b5e110d1e
9 changed files with 21 additions and 19 deletions

View File

@@ -138,7 +138,7 @@ version = 1
path = "\\sprout\\drivers\\ext4.efi"
# global options.
[defaults]
[options]
# enable autoconfiguration by detecting bls enabled
# filesystems and generating boot entries for them.
autoconfigure = true

View File

@@ -1,7 +1,7 @@
version = 1
[defaults]
entry = "kernel"
[options]
default-entry = "kernel"
[extractors.boot.filesystem-device-match]
has-item = "\\EFI\\BOOT\\kernel.efi"

View File

@@ -1,4 +1,4 @@
version = 1
[defaults]
[options]
autoconfigure = true

View File

@@ -1,7 +1,7 @@
version = 1
[defaults]
entry = "edera"
[options]
default-entry = "edera"
menu-timeout = 0
[extractors.boot.filesystem-device-match]

View File

@@ -1,7 +1,7 @@
version = 1
[defaults]
entry = "kernel"
[options]
default-entry = "kernel"
menu-timeout = 0
[extractors.boot.filesystem-device-match]

View File

@@ -1,7 +1,7 @@
version = 1
[defaults]
entry = "shell"
[options]
default-entry = "shell"
menu-timeout = 0
[extractors.boot.filesystem-device-match]

View File

@@ -1,7 +1,7 @@
version = 1
[defaults]
entry = "xen"
[options]
default-entry = "xen"
menu-timeout = 0
[extractors.boot.filesystem-device-match]

View File

@@ -27,7 +27,7 @@ pub struct RootConfiguration {
pub version: u32,
/// Default options for Sprout.
#[serde(default)]
pub defaults: DefaultsConfiguration,
pub options: OptionsConfiguration,
/// Values to be inserted into the root sprout context.
#[serde(default)]
pub values: BTreeMap<String, String>,
@@ -65,16 +65,18 @@ pub struct RootConfiguration {
pub phases: PhasesConfiguration,
}
/// Default 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)]
pub struct DefaultsConfiguration {
pub struct OptionsConfiguration {
/// The entry to boot without showing the boot menu.
/// If not specified, a boot menu is shown.
pub entry: Option<String>,
#[serde(rename = "default-entry", default)]
pub default_entry: Option<String>,
/// The timeout of the boot menu.
#[serde(rename = "menu-timeout", default = "default_menu_timeout")]
pub menu_timeout: u64,
/// Enables autoconfiguration of Sprout based on the environment.
#[serde(default)]
pub autoconfigure: bool,
}

View File

@@ -100,7 +100,7 @@ fn run() -> Result<()> {
// If --autoconfigure is specified or the loaded configuration has autoconfigure enabled,
// trigger the autoconfiguration mechanism.
if context.root().options().autoconfigure || config.defaults.autoconfigure {
if context.root().options().autoconfigure || config.options.autoconfigure {
autoconfigure::autoconfigure(&mut config).context("unable to autoconfigure")?;
}
@@ -182,7 +182,7 @@ fn run() -> Result<()> {
entry.restamp_title();
// Mark this entry as the default entry if it is declared as such.
if let Some(ref default_entry) = config.defaults.entry {
if let Some(ref default_entry) = config.options.default_entry {
// If the entry matches the default entry, mark it as the default entry.
if entry.is_match(default_entry) {
entry.mark_default();
@@ -211,7 +211,7 @@ fn run() -> Result<()> {
.root()
.options()
.menu_timeout
.unwrap_or(config.defaults.menu_timeout);
.unwrap_or(config.options.menu_timeout);
let menu_timeout = Duration::from_secs(menu_timeout);
// Use the forced boot entry if possible, otherwise pick the first entry using a boot menu.