diff --git a/README.md b/README.md index 254eba5..d704468 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/hack/dev/configs/all.sprout.toml b/hack/dev/configs/all.sprout.toml index c42ba93..0bcdb00 100644 --- a/hack/dev/configs/all.sprout.toml +++ b/hack/dev/configs/all.sprout.toml @@ -1,7 +1,7 @@ version = 1 -[defaults] -entry = "kernel" +[options] +default-entry = "kernel" [extractors.boot.filesystem-device-match] has-item = "\\EFI\\BOOT\\kernel.efi" diff --git a/hack/dev/configs/autoconfigure.sprout.toml b/hack/dev/configs/autoconfigure.sprout.toml index 9b7d56f..d0da704 100644 --- a/hack/dev/configs/autoconfigure.sprout.toml +++ b/hack/dev/configs/autoconfigure.sprout.toml @@ -1,4 +1,4 @@ version = 1 -[defaults] +[options] autoconfigure = true diff --git a/hack/dev/configs/edera.sprout.toml b/hack/dev/configs/edera.sprout.toml index 613d32d..75830ba 100644 --- a/hack/dev/configs/edera.sprout.toml +++ b/hack/dev/configs/edera.sprout.toml @@ -1,7 +1,7 @@ version = 1 -[defaults] -entry = "edera" +[options] +default-entry = "edera" menu-timeout = 0 [extractors.boot.filesystem-device-match] diff --git a/hack/dev/configs/kernel.sprout.toml b/hack/dev/configs/kernel.sprout.toml index dd9064e..c9983a4 100644 --- a/hack/dev/configs/kernel.sprout.toml +++ b/hack/dev/configs/kernel.sprout.toml @@ -1,7 +1,7 @@ version = 1 -[defaults] -entry = "kernel" +[options] +default-entry = "kernel" menu-timeout = 0 [extractors.boot.filesystem-device-match] diff --git a/hack/dev/configs/shell.sprout.toml b/hack/dev/configs/shell.sprout.toml index 79fafa3..9927e54 100644 --- a/hack/dev/configs/shell.sprout.toml +++ b/hack/dev/configs/shell.sprout.toml @@ -1,7 +1,7 @@ version = 1 -[defaults] -entry = "shell" +[options] +default-entry = "shell" menu-timeout = 0 [extractors.boot.filesystem-device-match] diff --git a/hack/dev/configs/xen.sprout.toml b/hack/dev/configs/xen.sprout.toml index e7e913d..64b0c1f 100644 --- a/hack/dev/configs/xen.sprout.toml +++ b/hack/dev/configs/xen.sprout.toml @@ -1,7 +1,7 @@ version = 1 -[defaults] -entry = "xen" +[options] +default-entry = "xen" menu-timeout = 0 [extractors.boot.filesystem-device-match] diff --git a/src/config.rs b/src/config.rs index a6affc3..4b50ead 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, @@ -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, + #[serde(rename = "default-entry", default)] + pub default_entry: Option, /// 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, } diff --git a/src/main.rs b/src/main.rs index 501b24c..d31158a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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.