pub mod diff;
pub mod generate;
pub mod import;
pub mod start;
pub mod time;
pub mod validate;
use self::time::TimeCommand;
use crate::cli::generate::{CommitteeIdCommandArgs, QrCommandArgs, SnapshotCommandArgs};
use crate::cli::start::AdvancedStartCommandArgs;
use crate::cli::start::{MockFarmCommand, MockStartCommandArgs};
use crate::Result;
use clap::Parser;
use diff::DiffCommand;
use generate::DataCommandArgs;
use import::ImportCommand;
use start::QuickStartCommandArgs;
pub use validate::Error as ValidateError;
use validate::ValidateCommand;
#[allow(clippy::large_enum_variant)]
#[derive(Parser, Debug)]
pub enum VitCliCommand {
#[clap(subcommand)]
Start(StartCommand),
#[clap(subcommand)]
Generate(GenerateCommand),
Diff(DiffCommand),
#[clap(subcommand)]
Validate(ValidateCommand),
#[clap(subcommand)]
Import(ImportCommand),
Time(TimeCommand),
}
impl VitCliCommand {
pub fn exec(self) -> Result<()> {
match self {
Self::Start(start_command) => start_command.exec(),
Self::Generate(generate_command) => generate_command.exec(),
Self::Diff(diff_command) => diff_command.exec(),
Self::Validate(validate_command) => validate_command.exec().map_err(Into::into),
Self::Import(import_command) => import_command.exec().map_err(Into::into),
Self::Time(time_command) => time_command.exec(),
}
}
}
#[derive(Parser, Debug)]
pub enum StartCommand {
Quick(QuickStartCommandArgs),
Advanced(AdvancedStartCommandArgs),
Mock(MockStartCommandArgs),
MockFarm(MockFarmCommand),
}
impl StartCommand {
pub fn exec(self) -> Result<()> {
match self {
Self::Quick(quick_start_command) => quick_start_command.exec(),
Self::Advanced(advanced_start_command) => advanced_start_command.exec(),
Self::Mock(mock_start_command) => mock_start_command.exec().map_err(Into::into),
Self::MockFarm(mock_farm_start_command) => {
mock_farm_start_command.exec().map_err(Into::into)
}
}
}
}
#[derive(Parser, Debug)]
pub enum GenerateCommand {
Qr(QrCommandArgs),
#[clap(subcommand)]
Data(DataCommandArgs),
Snapshot(SnapshotCommandArgs),
Committee(CommitteeIdCommandArgs),
}
impl GenerateCommand {
pub fn exec(self) -> Result<()> {
match self {
Self::Qr(quick_start_command) => quick_start_command.exec(),
Self::Data(data_start_command) => data_start_command.exec(),
Self::Snapshot(snapshot_start_command) => snapshot_start_command.exec(),
Self::Committee(generate_committee_command) => generate_committee_command.exec(),
}
}
}