2025-10-01 21:30:43 -07:00
|
|
|
use crate::utils;
|
2025-10-01 18:25:49 -07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-10-04 23:12:01 -07:00
|
|
|
use std::collections::BTreeMap;
|
2025-10-01 18:25:49 -07:00
|
|
|
|
2025-10-04 23:12:01 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
2025-10-01 18:25:49 -07:00
|
|
|
pub struct RootConfiguration {
|
2025-10-05 00:09:53 -07:00
|
|
|
#[serde(default = "latest_version")]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub version: u32,
|
2025-10-01 18:25:49 -07:00
|
|
|
#[serde(default)]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub values: BTreeMap<String, String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub actions: BTreeMap<String, ActionDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub entries: BTreeMap<String, EntryDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub generators: BTreeMap<String, GeneratorDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub phases: PhasesConfiguration,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct ActionDeclaration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub chainload: Option<ChainloadConfiguration>,
|
2025-10-05 00:09:53 -07:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub print: Option<PrintConfiguration>,
|
2025-10-05 03:12:00 -07:00
|
|
|
#[serde(default)]
|
|
|
|
|
#[cfg(feature = "splash")]
|
|
|
|
|
pub splash: Option<SplashConfiguration>,
|
2025-10-04 23:12:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct EntryDeclaration {
|
|
|
|
|
pub title: String,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub actions: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub values: BTreeMap<String, String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct GeneratorDeclaration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub matrix: Option<MatrixConfiguration>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct PhasesConfiguration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub startup: Vec<PhaseConfiguration>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct PhaseConfiguration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub actions: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub values: BTreeMap<String, String>,
|
2025-10-01 18:25:49 -07:00
|
|
|
}
|
|
|
|
|
|
2025-10-04 23:12:01 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct MatrixConfiguration {
|
2025-10-01 18:25:49 -07:00
|
|
|
#[serde(default)]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub entry: EntryDeclaration,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub values: BTreeMap<String, Vec<String>>,
|
2025-10-01 18:25:49 -07:00
|
|
|
}
|
|
|
|
|
|
2025-10-04 23:12:01 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct ChainloadConfiguration {
|
2025-10-01 18:25:49 -07:00
|
|
|
pub path: String,
|
2025-10-02 00:24:19 -07:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub options: Vec<String>,
|
2025-10-01 18:25:49 -07:00
|
|
|
}
|
|
|
|
|
|
2025-10-05 00:09:53 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct PrintConfiguration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub text: String,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-05 03:12:00 -07:00
|
|
|
#[cfg(feature = "splash")]
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct SplashConfiguration {
|
|
|
|
|
pub image: String,
|
|
|
|
|
#[serde(default = "default_splash_time")]
|
|
|
|
|
pub time: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "splash")]
|
|
|
|
|
pub fn default_splash_time() -> u32 {
|
|
|
|
|
5
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-01 18:25:49 -07:00
|
|
|
pub fn load() -> RootConfiguration {
|
2025-10-01 21:30:43 -07:00
|
|
|
let content = utils::read_file_contents("sprout.toml");
|
2025-10-01 18:25:49 -07:00
|
|
|
toml::from_slice(&content).expect("unable to parse sprout.toml file")
|
|
|
|
|
}
|
2025-10-04 23:12:01 -07:00
|
|
|
|
2025-10-05 00:09:53 -07:00
|
|
|
pub fn latest_version() -> u32 {
|
2025-10-04 23:12:01 -07:00
|
|
|
1
|
|
|
|
|
}
|