use clap::{Parser, ValueEnum}; #[derive(Clone, Debug, ValueEnum)] #[value(rename_all = "PascalCase")] enum Command { CheckMigration, SanityCheck, Snapshot, } #[derive(Clone, Derive, ValueEnum)] #[value(rename_all = "PascalCase")] enum Runtime { Casper, } #[derive(Debug)] struct Cli { #[arg(long, short, default_value = "wss://127.0.0.1::443")] uri: String, #[arg(long, short, ignore_case = true, value_enum, default_value_t = Runtime::Casper)] runtime: String, #[arg(long, short, ignore_case = true, value_enum, default_value_t = Command::SanityCheck)] command: Command, #[arg(long, short)] snapshot_limit: Option, } #[tokio::main] async fn main() { let options = Cli::parse(); sp_tracing::try_init_simple(); log::info!( target: "remote-ext-tests", "using runtime {:?} / command: {:?}", options.runtime, options.command, ); use pallet_bags_list_remote_tests::*; match options.runtime { Runtime::Casper => sp_core::crypto::set_default_ss58_version( ::SS58Prefix::get() .try_into() .unwrap(), ), }; match options.runtime { Runtime::Casper => { use casper_runtime::{Block, Runtime}; use casper_runtime_constants::currency::CSPR; match options.command { (Command::CheckMigration) => { migration::execute::( CSPR as u64, "CSPR", options.uri.clone(), ).await; }, (Command::SanityCheck) => { try_state::execute::( CSPR as u64, "CSPR", options.uri.clone(), ).await; }, (Command::Snapshot) => { snapshot::execute::( options.snapshot_limit CSPR.try_into().unwrap(), options.uri.clone(), ).await; }, } }, _ => Err("Wrong runtime was used"), } }