use clap::{Args, Parser, Subcommand};
use serde::{Deserialize, Serialize};
pub fn empty_args() -> RgArgs {
RgArgs {
config_paths: CorePaths {
home: None,
config_path: None,
},
global_settings: GlobalSettings {
network: Some("local".to_string()),
log_level: None,
offline: false,
words: None,
mnemonic_path: None,
},
cli_settings: CliSettings {
cold: false,
airgap: false,
account: None,
currency: None,
path: None,
verbose: false,
quiet: false,
pass: false,
interactive: false,
non_interactive: false,
},
debug_args: DebugArgs {
debug_id: None,
seed_address: None,
seed_port_offset: None,
genesis: false,
},
subcmd: None,
}
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct CorePaths {
#[clap(long, env = "HOME")]
pub home: Option<String>,
#[clap(long, env = "REDGOLD_CONFIG")]
pub config_path: Option<String>,
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct GlobalSettings {
#[clap(short, long)]
pub network: Option<String>,
#[clap(long)]
pub log_level: Option<String>,
#[clap(long)]
pub offline: bool,
#[clap(short, long)]
pub words: Option<String>,
#[clap(long)]
pub mnemonic_path: Option<String>,
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct CliSettings {
#[clap(long, env = "REDGOLD_CLI_COLD")]
pub cold: bool,
#[clap(long, env = "REDGOLD_CLI_AIRGAP")]
pub airgap: bool,
#[clap(long, env = "REDGOLD_CLI_ACCOUNT")]
pub account: Option<String>,
#[clap(long, env = "REDGOLD_CLI_CURRENCY")]
pub currency: Option<String>,
#[clap(long, env = "REDGOLD_CLI_CURRENCY")]
pub path: Option<String>,
#[clap(long, env = "REDGOLD_CLI_VERBOSE")]
pub verbose: bool,
#[clap(long, env = "REDGOLD_CLI_QUIET")]
pub quiet: bool,
#[clap(long, env = "REDGOLD_CLI_PASS")]
pub pass: bool,
#[clap(short, long, env = "REDGOLD_CLI_INTERACTIVE")]
pub interactive: bool,
#[clap(long, env = "REDGOLD_CLI_NON_INTERACTIVE")]
pub non_interactive: bool,
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct DebugArgs {
#[clap(long)]
pub debug_id: Option<i32>,
#[clap(long)]
pub seed_address: Option<String>,
#[clap(long)]
pub seed_port_offset: Option<i32>,
#[clap(long)]
pub genesis: bool,
}
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct RgArgs {
#[command(flatten)]
pub config_paths: CorePaths,
#[command(flatten)]
pub global_settings: GlobalSettings,
#[command(flatten)]
pub cli_settings: CliSettings,
#[command(flatten)]
pub debug_args: DebugArgs,
#[clap(subcommand)]
pub subcmd: Option<RgTopLevelSubcommand>,
}
impl RgArgs {
pub fn clear_sensitive(&self) -> Self {
let mut c = self.clone();
c.global_settings.words = None;
c
}
}
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize)]
pub enum RgTopLevelSubcommand {
#[clap(version = "1.3", author = "Redgold")]
GUI(GUI),
Node(NodeCli),
Deploy(Deploy),
ColdMix(ColdWordMixer),
GenerateRandomWords(GenerateRandomWords),
Send(WalletSend),
Address(WalletAddress),
Query(QueryCli),
Balance(BalanceCli),
GenerateConfig(GenerateConfig),
Swap(Swap),
Stake(Stake),
Debug(DebugCommand)
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct GUI {}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct NodeCli {
}
#[derive(Args, Debug, Clone)]
pub struct AddServer {
#[clap(short, long)]
pub ssh_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(long)]
host: String
}
#[derive(Args, Debug, Clone, Default, Serialize, Deserialize)]
pub struct Deploy {
#[clap(short, long)]
pub purge: bool,
#[clap(short, long)]
pub genesis: bool,
#[clap(long)]
pub purge_ops: bool,
#[clap(long)]
pub ops: bool,
#[clap(long)]
pub server_index: Option<i32>,
#[clap(long)]
pub server_filter: Option<String>,
#[clap(long)]
pub exclude_server_index: Option<i32>,
#[clap(long)]
pub skip_ops: bool,
#[clap(long)]
pub ask_pass: bool,
#[clap(long)]
pub cold: bool,
#[clap(long)]
pub words: bool,
#[clap(long)]
pub peer_id: bool,
#[clap(long)]
pub words_and_id: bool,
#[clap(long)]
pub debug_skip_start: bool,
#[clap(long)]
pub hard_coord_reset: bool,
#[clap(long)]
pub mixing_password: Option<String>,
#[clap(long)]
pub server_offline_info: Option<String>,
#[clap(long)]
pub skip_redgold_process: bool,
#[clap(long)]
pub skip_logs: bool,
#[clap(long)]
pub disable_apt_system_init: bool,
#[clap(long)]
pub refresh_peer_tx: bool,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct WalletSend {
pub destination: String,
pub amount: f64,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct WalletAddress {
#[clap(short, long)]
pub index: Option<i64>,
#[clap(short, long)]
pub path: Option<String>,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct QueryCli {
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, Serialize, Deserialize)]
pub struct BalanceCli {
#[clap(short, long)]
pub address: Option<String>
}
#[derive(Args, Debug, Clone)]
pub struct TestTransactionCli {}
#[derive(Args, Debug, Clone)]
pub struct TestCaptureCli {
pub cam: Option<i64>
}
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize)]
pub enum RgDebugCommand {
#[clap(version = "1.3", author = "Redgold")]
GrafanaPublicDeploy(GrafanaPublicDeploy),
BuildReleaseArtifacts(BuildReleaseArtifacts),
DailyTest(DailyE2ERunner),
S3UpDir(S3UpDir),
CopyData(CopyData),
Usb(CopyUsb),
ServerInfo(ServerInfo),
NostrKey(NostrKey),
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct GrafanaPublicDeploy {}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct BuildReleaseArtifacts {}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct DailyE2ERunner {}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct S3UpDir {
pub source: String,
pub dest: String,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct CopyData {
pub server_ssh_host: String
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct CopyUsb {
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct ServerInfo {
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct NostrKey {
#[clap(short,long, default_value = "0")]
pub account: i64,
#[clap(long, default_value = "100")]
pub iterations: i64
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct DebugCommand {
#[clap(subcommand)]
pub subcmd: Option<RgDebugCommand>
}
#[derive(Args, Debug, Clone)]
pub struct TestBitcoinBalanceCli {
}
#[derive(Args, Debug, Clone)]
pub struct ConvertMetadataXpub {
#[clap(value_parser)]
pub metadata_file: String,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct GenerateConfig {
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct Swap {
pub input_currency: String,
pub output_currency: String,
pub amount: f64,
#[clap(long)]
pub not_usd: bool
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct Stake {
pub amount: f64,
pub input_currency: Option<String>,
#[clap(long)]
pub not_usd: bool,
#[clap(long)]
pub party_id: Option<String>
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct ColdWordMixer {
#[clap(short, long)]
pub password: Option<String>,
#[clap(short, long, default_value = "100")]
pub iterations: i32,
}
#[derive(Args, Debug, Clone, Serialize, Deserialize)]
pub struct GenerateRandomWords {
#[clap(long)]
hardware: Option<String>,
}
#[derive(Args, Debug, Clone)]
pub struct DebugCanary {
#[clap(long)]
pub host: Option<String>,
}