mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
Add a "check-config" command to validate config files & tests for it
This commit is contained in:
parent
70ee206031
commit
26ba489aa3
24 changed files with 492 additions and 0 deletions
20
src/cli.rs
20
src/cli.rs
|
|
@ -12,6 +12,7 @@ use crate::{
|
|||
error, observability,
|
||||
};
|
||||
|
||||
mod check_config;
|
||||
mod serve;
|
||||
|
||||
/// Command line arguments
|
||||
|
|
@ -29,6 +30,18 @@ pub(crate) struct Args {
|
|||
pub(crate) enum Command {
|
||||
/// Run the server.
|
||||
Serve(ServeArgs),
|
||||
|
||||
/// Check the configuration file for syntax and semantic errors.
|
||||
CheckConfig(CheckConfigArgs),
|
||||
}
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub(crate) struct CheckConfigArgs {
|
||||
#[clap(flatten)]
|
||||
config: ConfigArg,
|
||||
|
||||
#[clap(flatten)]
|
||||
observability: ObservabilityArgs,
|
||||
}
|
||||
|
||||
/// Wrapper for the `--config` arg.
|
||||
|
|
@ -83,6 +96,9 @@ impl Args {
|
|||
|
||||
match self.command {
|
||||
Command::Serve(args) => serve::run(args).await?,
|
||||
Command::CheckConfig(args) => {
|
||||
check_config::run(args.config).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -93,6 +109,10 @@ impl Command {
|
|||
// All subcommands other than `serve` should return `Some`. Keep these
|
||||
// match arms sorted by the enum variant name.
|
||||
match self {
|
||||
Command::CheckConfig(args) => Some((
|
||||
args.observability.log_format,
|
||||
args.observability.log_filter.clone(),
|
||||
)),
|
||||
Command::Serve(_) => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue