36 lines
782 B
Rust
36 lines
782 B
Rust
mod migrate;
|
|
mod schema;
|
|
mod validate;
|
|
|
|
use clap::{Subcommand, ValueEnum};
|
|
|
|
#[derive(Subcommand)]
|
|
pub(crate) enum Commands {
|
|
/// Convert an old config file into the new format
|
|
Migrate { version: ConfigVersion },
|
|
/// Validate the config file
|
|
Validate,
|
|
}
|
|
|
|
#[derive(Clone, ValueEnum)]
|
|
pub(crate) enum ConfigVersion {
|
|
#[clap(name = "20240701")]
|
|
V20240701,
|
|
}
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub(crate) enum Error {
|
|
#[error(transparent)]
|
|
Migrate(#[from] migrate::Error),
|
|
#[error(transparent)]
|
|
Validate(#[from] validate::Error),
|
|
}
|
|
|
|
pub(crate) fn run(command: Commands) -> Result<(), Error> {
|
|
match command {
|
|
Commands::Migrate { version } => migrate::run(version)?,
|
|
Commands::Validate => validate::run()?,
|
|
}
|
|
|
|
Ok(())
|
|
}
|