diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf059ad..8f78f190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added config validations. + - sfsu will now crash with an error message if `no_junction` is enabled. - Added `app download --outdated` flag to download new versions of all outdated apps ### Changed diff --git a/src/main.rs b/src/main.rs index fcfb79d9..22cb3efd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ mod limits; mod logging; mod models; mod output; +mod validations; mod wrappers; use std::{ @@ -26,10 +27,11 @@ use clap::Parser; use commands::Commands; use logging::Logger; -use sprinkles::contexts::{AnyContext, User}; +use sprinkles::contexts::{AnyContext, ScoopContext, User}; #[cfg(feature = "contexts")] use sprinkles::contexts::Global; +use validations::Validate; shadow_rs::shadow!(shadow); @@ -171,6 +173,8 @@ async fn main() -> anyhow::Result<()> { COLOR_ENABLED.store(false, Ordering::Relaxed); } + ctx.config().validate()?; + debug!("Running command: {:?}", args.command); args.command.run(&ctx).await?; diff --git a/src/validations.rs b/src/validations.rs new file mode 100644 index 00000000..07d3c7dc --- /dev/null +++ b/src/validations.rs @@ -0,0 +1,5 @@ +pub mod config; + +pub trait Validate { + fn validate(&self) -> anyhow::Result<()>; +} diff --git a/src/validations/config.rs b/src/validations/config.rs new file mode 100644 index 00000000..e8c934be --- /dev/null +++ b/src/validations/config.rs @@ -0,0 +1,10 @@ +impl super::Validate for sprinkles::config::Scoop { + fn validate(&self) -> anyhow::Result<()> { + if self.no_junction { + anyhow::bail!("Junction links (symlinks) are required for sfsu to function currently. Please disable `no_junction` in your Scoop + config"); + } + + Ok(()) + } +}