Skip to content

Commit

Permalink
add a config-file cli argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Sep 5, 2024
1 parent c78f764 commit e615052
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ pub struct Cli {
#[clap(short, long)]
pub web_root: Option<PathBuf>,
/// The directory where the sqlpage.json configuration, the templates, and the migrations are located.
#[clap(short, long)]
#[clap(short = 'd', long)]
pub config_dir: Option<PathBuf>,
/// The path to the configuration file.
#[clap(short = 'c', long)]
pub config_file: Option<PathBuf>,
}

#[cfg(not(feature = "lambda-web"))]
const DEFAULT_DATABASE_FILE: &str = "sqlpage.db";

impl AppConfig {
pub fn from_cli(cli: &Cli) -> anyhow::Result<Self> {
let mut config = if let Some(config_dir) = &cli.config_dir {
let mut config = if let Some(config_file) = &cli.config_file {
load_from_file(config_file)?
} else if let Some(config_dir) = &cli.config_dir {
load_from_directory(config_dir)?
} else {
load_from_env()?
Expand Down Expand Up @@ -134,7 +139,8 @@ pub struct AppConfig {
#[serde(default = "default_compress_responses")]
pub compress_responses: bool,

/// Content-Security-Policy header to send to the client. If not set, a default policy allowing scripts from the same origin is used and from jsdelivr.net
/// Content-Security-Policy header to send to the client.
/// If not set, a default policy allowing scripts from the same origin is used and from jsdelivr.net
pub content_security_policy: Option<String>,

/// Whether `sqlpage.fetch` should load trusted certificates from the operating system's certificate store
Expand Down

0 comments on commit e615052

Please sign in to comment.