use crate::faucet::FaucetArgs;
use crate::identity::IdentitySubcommands;
use crate::network_registry::NetworkRegistrySubcommands;
use crate::safe_module::SafeModuleSubcommands;
use crate::utils::{Cmd, HelperErrors};
use crate::win_prob::WinProbSubcommands;
use clap::{Parser, Subcommand};
use tracing_subscriber::layer::SubscriberExt;
pub mod environment_config;
pub mod faucet;
pub mod identity;
pub mod key_pair;
pub mod methods;
pub mod network_registry;
pub mod safe_module;
pub mod utils;
pub mod win_prob;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
enum Commands {
#[command(visible_alias = "id")]
Identity {
#[command(subcommand)]
command: IdentitySubcommands,
},
#[clap(about = "Fund given address and/or addressed derived from identity files native tokens or HOPR tokens")]
Faucet(FaucetArgs),
#[command(visible_alias = "nr")]
NetworkRegistry {
#[command(subcommand)]
command: NetworkRegistrySubcommands,
},
#[command(visible_alias = "sm")]
SafeModule {
#[command(subcommand)]
command: SafeModuleSubcommands,
},
#[command(visible_alias = "wp")]
WinProb {
#[command(subcommand)]
command: WinProbSubcommands,
},
}
#[async_std::main]
async fn main() -> Result<(), HelperErrors> {
let env_filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
let format = tracing_subscriber::fmt::layer()
.with_level(true)
.with_target(true)
.with_thread_ids(true)
.with_thread_names(false);
let subscriber = tracing_subscriber::Registry::default().with(env_filter).with(format);
tracing::subscriber::set_global_default(subscriber).expect("Failed to set tracing subscriber");
let cli = Cli::parse();
match cli.command {
Commands::Identity { command } => {
command.run()?;
}
Commands::Faucet(opt) => {
opt.async_run().await?;
}
Commands::NetworkRegistry { command } => {
command.async_run().await?;
}
Commands::SafeModule { command } => {
command.async_run().await?;
}
Commands::WinProb { command } => {
command.async_run().await?;
}
}
Ok(())
}