Skip to content

Commit

Permalink
added config validations
Browse files Browse the repository at this point in the history
  • Loading branch information
jewlexx committed Nov 27, 2024
1 parent 682913e commit 23297e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod limits;
mod logging;
mod models;
mod output;
mod validations;
mod wrappers;

use std::{
Expand All @@ -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);

Expand Down Expand Up @@ -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?;
Expand Down
5 changes: 5 additions & 0 deletions src/validations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod config;

pub trait Validate {
fn validate(&self) -> anyhow::Result<()>;
}
10 changes: 10 additions & 0 deletions src/validations/config.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
}

0 comments on commit 23297e6

Please sign in to comment.