1use crate::faucet::FaucetArgs;
4use crate::identity::IdentitySubcommands;
5use crate::network_registry::NetworkRegistrySubcommands;
6use crate::safe_module::SafeModuleSubcommands;
7use crate::utils::{Cmd, HelperErrors};
8use crate::win_prob::WinProbSubcommands;
9use clap::{Parser, Subcommand};
10use tracing_subscriber::layer::SubscriberExt;
11pub mod environment_config;
12pub mod faucet;
13pub mod identity;
14pub mod key_pair;
15pub mod methods;
16pub mod network_registry;
17pub mod safe_module;
18pub mod utils;
19pub mod win_prob;
20
21#[derive(Parser, Debug)]
22#[command(author, version, about, long_about = None)]
23struct Cli {
24 #[command(subcommand)]
25 pub command: Commands,
26}
27
28#[derive(Subcommand, Debug)]
30enum Commands {
31 #[command(visible_alias = "id")]
33 Identity {
34 #[command(subcommand)]
35 command: IdentitySubcommands,
36 },
37
38 #[clap(about = "Fund given address and/or addressed derived from identity files native tokens or HOPR tokens")]
40 Faucet(FaucetArgs),
41
42 #[command(visible_alias = "nr")]
44 NetworkRegistry {
45 #[command(subcommand)]
46 command: NetworkRegistrySubcommands,
47 },
48
49 #[command(visible_alias = "sm")]
51 SafeModule {
52 #[command(subcommand)]
53 command: SafeModuleSubcommands,
54 },
55
56 #[command(visible_alias = "wp")]
58 WinProb {
59 #[command(subcommand)]
60 command: WinProbSubcommands,
61 },
62}
63
64#[async_std::main]
65async fn main() -> Result<(), HelperErrors> {
66 let env_filter = tracing_subscriber::EnvFilter::try_from_default_env()
67 .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
68 let format = tracing_subscriber::fmt::layer()
69 .with_level(true)
70 .with_target(true)
71 .with_thread_ids(true)
72 .with_thread_names(false);
73
74 let subscriber = tracing_subscriber::Registry::default().with(env_filter).with(format);
75
76 tracing::subscriber::set_global_default(subscriber).expect("Failed to set tracing subscriber");
77
78 let cli = Cli::parse();
79
80 match cli.command {
81 Commands::Identity { command } => {
82 command.run()?;
83 }
84 Commands::Faucet(opt) => {
85 opt.async_run().await?;
86 }
87 Commands::NetworkRegistry { command } => {
88 command.async_run().await?;
89 }
90 Commands::SafeModule { command } => {
91 command.async_run().await?;
92 }
93 Commands::WinProb { command } => {
94 command.async_run().await?;
95 }
96 }
97
98 Ok(())
99}