1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::config::read_config;
use clap::Parser;
use std::path::PathBuf;
use thiserror::Error;

#[derive(Parser, Debug)]
pub struct ConfigValidateCommand {
    /// target config
    #[clap(name = "CONFIG")]
    pub config: PathBuf,
}

impl ConfigValidateCommand {
    pub fn exec(self) -> Result<(), Error> {
        read_config(self.config)
            .map(|_| ())
            .map_err(|e| Error::ValidationError(e.to_string()))
    }
}

#[derive(Debug, Error)]
pub enum Error {
    #[error("validation error: '{0}'")]
    ValidationError(String),
}