mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 17:30:17 +00:00
rearrange configuration to be closer to where it's consumed
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use crate::actions::ActionDeclaration;
|
||||
use crate::generators::GeneratorDeclaration;
|
||||
use crate::utils;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
@@ -18,17 +20,6 @@ pub struct RootConfiguration {
|
||||
pub phases: PhasesConfiguration,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct ActionDeclaration {
|
||||
#[serde(default)]
|
||||
pub chainload: Option<ChainloadConfiguration>,
|
||||
#[serde(default)]
|
||||
pub print: Option<PrintConfiguration>,
|
||||
#[serde(default)]
|
||||
#[cfg(feature = "splash")]
|
||||
pub splash: Option<SplashConfiguration>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct EntryDeclaration {
|
||||
pub title: String,
|
||||
@@ -38,12 +29,6 @@ pub struct EntryDeclaration {
|
||||
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)]
|
||||
@@ -58,40 +43,6 @@ pub struct PhaseConfiguration {
|
||||
pub values: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct MatrixConfiguration {
|
||||
#[serde(default)]
|
||||
pub entry: EntryDeclaration,
|
||||
#[serde(default)]
|
||||
pub values: BTreeMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct ChainloadConfiguration {
|
||||
pub path: String,
|
||||
#[serde(default)]
|
||||
pub options: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct PrintConfiguration {
|
||||
#[serde(default)]
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
#[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
|
||||
}
|
||||
|
||||
pub fn load() -> RootConfiguration {
|
||||
let content = utils::read_file_contents("sprout.toml");
|
||||
toml::from_slice(&content).expect("unable to parse sprout.toml file")
|
||||
|
||||
Reference in New Issue
Block a user