fishctl/src/command/config.rs

38 lines
834 B
Rust
Raw Normal View History

2024-06-20 08:17:13 +09:00
//! `config` subcommand
2024-06-20 02:07:34 +09:00
mod migrate;
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)]
2024-06-20 02:42:33 +09:00
Migrate(#[from] migrate::ConfigMigrateError),
2024-06-20 02:07:34 +09:00
#[error(transparent)]
2024-06-20 02:42:33 +09:00
Validate(#[from] validate::ConfigValidateError),
2024-06-20 02:07:34 +09:00
}
2024-06-20 03:19:20 +09:00
pub(crate) async fn run(command: Commands) -> Result<(), Error> {
2024-06-20 02:07:34 +09:00
match command {
2024-06-20 03:19:20 +09:00
Commands::Migrate { version } => migrate::run(version).await?,
2024-06-20 02:07:34 +09:00
Commands::Validate => validate::run()?,
}
Ok(())
}