diff --git a/README.md b/README.md index 39284b4..ea128e3 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,12 @@ fishctl config validate Note that some items are only formally checked, so even if the output says it is valid, your settings may not be appropriate. +This command performs a connection check against the PostgreSQL server and the Redis/Valkey server. To turn it off, provide the `--offline` option: + +```sh +fishctl config validate --offline +``` + ### Generate VAPID keys for push notifications ```sh diff --git a/src/command/config.rs b/src/command/config.rs index 5d1827a..92d5c8e 100644 --- a/src/command/config.rs +++ b/src/command/config.rs @@ -17,7 +17,11 @@ pub(crate) enum Commands { /// Convert old config files to the new format Update { revision: Option }, /// Validate the config files - Validate, + Validate { + #[arg(short, long)] + /// Do not perform connection checks against database and cache servers + offline: bool, + }, } /// Errors that can happen in `config` subcommand @@ -32,7 +36,7 @@ pub(crate) enum ConfigError { pub(super) async fn run(command: Commands) -> Result<(), ConfigError> { match command { Commands::Update { revision } => update::run(revision).await?, - Commands::Validate => validate::run()?, + Commands::Validate { offline } => validate::run(offline)?, } Ok(()) } diff --git a/src/command/config/validate.rs b/src/command/config/validate.rs index 7ff8da0..998c27c 100644 --- a/src/command/config/validate.rs +++ b/src/command/config/validate.rs @@ -19,7 +19,7 @@ pub(crate) enum ValidationError { InvalidConfig, } -pub(super) fn run() -> Result<(), ValidationError> { +pub(super) fn run(bypass_connection_checks: bool) -> Result<(), ValidationError> { if current_revision()?.next().is_some() { cprintln!("Please first run `fishctl config update` to update your config files."); return Err(ValidationError::OutOfDate); @@ -66,5 +66,9 @@ pub(super) fn run() -> Result<(), ValidationError> { cprintln!("Note: This command only checks the format of the config files, and its result does not guarantee the correctness of the value."); } + if !bypass_connection_checks { + todo!() + } + server_validation_result.and(client_validation_result) }