mod data_loader;
mod updater;
use crate::cli::config::Config;
use std::process::ExitCode;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
pub struct VtOption {
#[clap(subcommand)]
pub vt: Vt,
}
#[derive(Subcommand, Debug)]
pub enum Vt {
Updater(updater::Updater),
Loader(data_loader::DataLoader),
}
impl VtOption {
pub async fn execute(self) -> Result<ExitCode> {
match self.vt {
Vt::Updater(u) => u.execute().await,
Vt::Loader(l) => l.execute().await,
}
}
}
#[derive(Subcommand, Debug)]
enum VtConfig {
Load(Load),
Config(Config),
}
#[derive(Parser, Debug)]
struct Load {
#[arg(value_name = "FILE", value_hint = clap::ValueHint::FilePath)]
pub file: std::path::PathBuf,
}
impl Load {
fn config(self) -> Result<Config> {
Config::from_file(&self.file)
}
}
impl VtConfig {
pub fn config(self) -> Result<Config> {
match self {
VtConfig::Load(loader) => loader.config(),
VtConfig::Config(config) => Ok(config),
}
}
}