Skip to content

Commit

Permalink
Merge pull request #905 from winpax/no-junction
Browse files Browse the repository at this point in the history
added config validations
  • Loading branch information
jewlexx authored Dec 4, 2024
2 parents b264c7a + ff1dcc3 commit 052380e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 052380e

Please sign in to comment.