use clap::{Args, Parser, Subcommand};
pub fn empty_args() -> RgArgs {
RgArgs {
config_path: None,
words: None,
mnemonic_path: None,
peer_id: None,
peer_id_path: None,
data_folder: None,
network: Some("local".to_string()),
debug_id: None,
disable_auto_update: false,
subcmd: None,
genesis: false,
seed_address: None,
seed_port_offset: None,
enable_e2e: true,
disable_e2e: false,
log_level: None,
}
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct RgArgs {
#[clap(short, long)]
pub config_path: Option<String>,
#[clap(short, long)]
pub words: Option<String>,
#[clap(long)]
pub mnemonic_path: Option<String>,
#[clap(short, long)]
pub peer_id: Option<String>,
#[clap(long)]
pub peer_id_path: Option<String>,
#[clap(long)]
pub data_folder: Option<String>,
#[clap(long)]
pub network: Option<String>,
#[clap(long)]
pub debug_id: Option<i32>,
#[clap(long)]
pub disable_auto_update: bool,
#[clap(subcommand)]
pub subcmd: Option<RgTopLevelSubcommand>,
#[clap(long)]
pub genesis: bool,
#[clap(long)]
pub seed_address: Option<String>,
#[clap(long)]
pub seed_port_offset: Option<i32>,
#[clap(long)]
pub enable_e2e: bool,
#[clap(long)]
pub disable_e2e: bool,
#[clap(long)]
pub log_level: Option<String>,
}
impl Default for RgArgs {
fn default() -> RgArgs {
empty_args()
}
}
#[derive(Subcommand, Debug, Clone)]
pub enum RgTopLevelSubcommand {
#[clap(version = "1.3", author = "Redgold")]
GUI(GUI),
Node(NodeCli),
AddServer(AddServer),
SetServersCsv(SetServersCsv),
RemoveServer(RemoveServer),
DebugCanary(DebugCanary),
Deploy(Deploy),
GenerateWords(GenerateMnemonic),
GenerateRandomWords(GenerateRandomWords),
Send(WalletSend),
Address(WalletAddress),
Query(QueryCli),
Faucet(FaucetCli),
Balance(BalanceCli),
TestTransaction(TestTransactionCli),
}
#[derive(Args, Debug, Clone)]
pub struct GUI {}
#[derive(Args, Debug, Clone)]
pub struct NodeCli {
#[clap(long)]
pub debug_enable_faucet: bool,
#[clap(long)]
pub live_e2e_interval: Option<u64>
}
#[derive(Args, Debug, Clone)]
pub struct AddServer {
#[clap(short, long)]
pub host: String,
#[clap(short, long)]
pub user: Option<String>,
#[clap(short, long)]
pub key_path: Option<String>,
#[clap(short, long)]
pub index: Option<i64>,
#[clap(short, long)]
pub peer_id_index: Option<i64>
}
#[derive(Args, Debug, Clone)]
pub struct SetServersCsv {
#[clap(short, long)]
pub path: String
}
#[derive(Args, Debug, Clone)]
pub struct RemoveServer {
#[clap(short, long)]
host: String
}
#[derive(Args, Debug, Clone)]
pub struct Deploy {
#[clap(short, long)]
pub purge: bool,
#[clap(short, long)]
pub wizard: bool,
#[clap(short, long)]
pub genesis: bool,
}
#[derive(Args, Debug, Clone)]
pub struct WalletSend {
#[clap(short, long)]
pub to: String,
#[clap(short, long)]
pub amount: f64,
#[clap(short, long)]
pub from: Option<String>,
}
#[derive(Args, Debug, Clone)]
pub struct WalletAddress {
#[clap(short, long)]
pub index: Option<i64>,
#[clap(short, long)]
pub path: Option<String>,
}
#[derive(Args, Debug, Clone)]
pub struct QueryCli {
#[clap(long)]
pub hash: String,
}
#[derive(Args, Debug, Clone)]
pub struct FaucetCli {
#[clap(short, long)]
pub to: String,
#[clap(short, long)]
pub amount: Option<f64>,
}
#[derive(Args, Debug, Clone)]
pub struct BalanceCli {
#[clap(short, long)]
pub address: String
}
#[derive(Args, Debug, Clone)]
pub struct TestTransactionCli {}
#[derive(Args, Debug, Clone)]
pub struct GenerateMnemonic {
#[clap(short, long)]
password: Option<String>,
#[clap(short, long, default_value = "10000")]
rounds: i32,
#[clap(short, long)]
use_random_seed: bool
}
#[derive(Args, Debug, Clone)]
pub struct GenerateRandomWords {
#[clap(short, long)]
hardware: Option<String>,
}
#[derive(Args, Debug, Clone)]
pub struct DebugCanary {
#[clap(long)]
pub host: Option<String>,
}