mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
splitting clap related code on apps in bin/
This commit is contained in:
@@ -8,13 +8,13 @@ use easy_parallel::Parallel;
|
||||
use log::{debug, info};
|
||||
use rand::rngs::OsRng;
|
||||
use serde_json::{json, Value};
|
||||
use simplelog::{ColorChoice, LevelFilter, TermLogger, TerminalMode};
|
||||
use simplelog::{ColorChoice, TermLogger, TerminalMode};
|
||||
|
||||
use darkfi::{
|
||||
blockchain::{rocks::columns, Rocks, RocksColumn},
|
||||
cli::{
|
||||
cli_config::{log_config, spawn_config},
|
||||
CashierdConfig, CliCashierd, Config,
|
||||
CashierdConfig, Config,
|
||||
},
|
||||
crypto::{
|
||||
address::Address,
|
||||
@@ -39,6 +39,24 @@ use darkfi::{
|
||||
|
||||
use cashierd::service::{bridge, bridge::Bridge};
|
||||
|
||||
/// Cashierd cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "cashierd")]
|
||||
pub struct CliCashierd {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Get Cashier Public key
|
||||
#[clap(short, long)]
|
||||
pub address: bool,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
/// Refresh the wallet and slabstore
|
||||
#[clap(short, long)]
|
||||
pub refresh: bool,
|
||||
}
|
||||
|
||||
const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../cashierd_config.toml");
|
||||
|
||||
fn handle_bridge_error(error_code: u32) -> Result<()> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use async_executor::Executor;
|
||||
use clap::{IntoApp, Parser};
|
||||
use clap::{IntoApp, Parser, Subcommand};
|
||||
use darkfi::{
|
||||
cli::{CliDao, CliDaoSubCommands, Config},
|
||||
cli::Config,
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult},
|
||||
util::async_util,
|
||||
Error, Result,
|
||||
@@ -10,6 +10,22 @@ use log::{debug, error};
|
||||
use serde_json::{json, Value};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CliDaoSubCommands {
|
||||
/// Say hello to the RPC
|
||||
Hello {},
|
||||
}
|
||||
|
||||
/// DAO cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "dao")]
|
||||
pub struct CliDao {
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<CliDaoSubCommands>,
|
||||
}
|
||||
pub struct Client {
|
||||
url: String,
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use darkfi::{
|
||||
blockchain::{rocks::columns, Rocks, RocksColumn},
|
||||
cli::{
|
||||
cli_config::{log_config, spawn_config},
|
||||
CliDarkfid, Config, DarkfidConfig,
|
||||
Config, DarkfidConfig,
|
||||
},
|
||||
crypto::{
|
||||
address::Address,
|
||||
@@ -41,6 +41,24 @@ use darkfi::{
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// Darkfid cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "darkfid")]
|
||||
pub struct CliDarkfid {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Local cashier public key
|
||||
#[clap(long)]
|
||||
pub cashier: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
/// Refresh the wallet and slabstore
|
||||
#[clap(short, long)]
|
||||
pub refresh: bool,
|
||||
}
|
||||
|
||||
const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../darkfid_config.toml");
|
||||
|
||||
pub const ETH_NATIVE_TOKEN_ID: &str = "0x0000000000000000000000000000000000000000";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
|
||||
use clap::{IntoApp, Parser};
|
||||
use clap::{AppSettings, IntoApp, Parser, Subcommand};
|
||||
use log::{debug, error};
|
||||
use prettytable::{cell, format, row, Table};
|
||||
use serde_json::{json, Value};
|
||||
@@ -9,13 +9,114 @@ use simplelog::{ColorChoice, TermLogger, TerminalMode};
|
||||
use darkfi::{
|
||||
cli::{
|
||||
cli_config::{log_config, spawn_config},
|
||||
CliDrk, CliDrkSubCommands, Config, DrkConfig,
|
||||
Config, DrkConfig,
|
||||
},
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult},
|
||||
util::{join_config_path, path::expand_path, NetworkName},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CliDrkSubCommands {
|
||||
/// Say hello to the RPC
|
||||
Hello {},
|
||||
/// Show what features the cashier supports
|
||||
Features {},
|
||||
/// Wallet operations
|
||||
Wallet {
|
||||
/// Initialize a new wallet
|
||||
#[clap(long)]
|
||||
create: bool,
|
||||
/// Generate wallet keypair
|
||||
#[clap(long)]
|
||||
keygen: bool,
|
||||
/// Get default wallet address
|
||||
#[clap(long)]
|
||||
address: bool,
|
||||
/// Get wallet addresses
|
||||
#[clap(long)]
|
||||
addresses: bool,
|
||||
/// Set default address
|
||||
#[clap(long, value_name = "ADDRESS")]
|
||||
set_default_address: Option<String>,
|
||||
/// Export default address
|
||||
#[clap(long, value_name = "PATH")]
|
||||
export_keypair: Option<String>,
|
||||
/// Import address
|
||||
#[clap(long, value_name = "PATH")]
|
||||
import_keypair: Option<String>,
|
||||
/// Get wallet balances
|
||||
#[clap(long)]
|
||||
balances: bool,
|
||||
},
|
||||
/// Get hexidecimal ID for token symbol
|
||||
Id {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to query (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token: String,
|
||||
},
|
||||
/// Withdraw Dark tokens for clear tokens
|
||||
Withdraw {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to receive (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
/// Recipient address
|
||||
#[clap(parse(try_from_str))]
|
||||
address: String,
|
||||
/// Amount to withdraw
|
||||
#[clap(parse(try_from_str))]
|
||||
amount: u64,
|
||||
},
|
||||
/// Transfer Dark tokens to address
|
||||
Transfer {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to transfer (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
/// Recipient address
|
||||
#[clap(parse(try_from_str))]
|
||||
address: String,
|
||||
/// Amount to transfer
|
||||
#[clap(parse(try_from_str))]
|
||||
amount: f64,
|
||||
},
|
||||
/// Deposit clear tokens for Dark tokens
|
||||
Deposit {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to deposit (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
},
|
||||
}
|
||||
|
||||
/// Drk cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "drk")]
|
||||
#[clap(author, version, about)]
|
||||
#[clap(global_setting(AppSettings::PropagateVersion))]
|
||||
#[clap(global_setting(AppSettings::UseLongFormatForHelpSubcommand))]
|
||||
#[clap(setting(AppSettings::SubcommandRequiredElseHelp))]
|
||||
pub struct CliDrk {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<CliDrkSubCommands>,
|
||||
}
|
||||
|
||||
const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../drk_config.toml");
|
||||
|
||||
struct Drk {
|
||||
|
||||
@@ -10,13 +10,25 @@ use darkfi::{
|
||||
blockchain::{rocks::columns, Rocks, RocksColumn},
|
||||
cli::{
|
||||
cli_config::{log_config, spawn_config},
|
||||
CliGatewayd, Config, GatewaydConfig,
|
||||
Config, GatewaydConfig,
|
||||
},
|
||||
node::service::gateway::GatewayService,
|
||||
util::{expand_path, join_config_path},
|
||||
Result,
|
||||
};
|
||||
|
||||
/// Gatewayd cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "gatewayd")]
|
||||
pub struct CliGatewayd {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
}
|
||||
|
||||
const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../gatewayd_config.toml");
|
||||
|
||||
async fn start(executor: Arc<Executor<'_>>, config: &GatewaydConfig) -> Result<()> {
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
use clap::{AppSettings, Parser, Subcommand};
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CliDrkSubCommands {
|
||||
/// Say hello to the RPC
|
||||
Hello {},
|
||||
/// Show what features the cashier supports
|
||||
Features {},
|
||||
/// Wallet operations
|
||||
Wallet {
|
||||
/// Initialize a new wallet
|
||||
#[clap(long)]
|
||||
create: bool,
|
||||
/// Generate wallet keypair
|
||||
#[clap(long)]
|
||||
keygen: bool,
|
||||
/// Get default wallet address
|
||||
#[clap(long)]
|
||||
address: bool,
|
||||
/// Get wallet addresses
|
||||
#[clap(long)]
|
||||
addresses: bool,
|
||||
/// Set default address
|
||||
#[clap(long, value_name = "ADDRESS")]
|
||||
set_default_address: Option<String>,
|
||||
/// Export default address
|
||||
#[clap(long, value_name = "PATH")]
|
||||
export_keypair: Option<String>,
|
||||
/// Import address
|
||||
#[clap(long, value_name = "PATH")]
|
||||
import_keypair: Option<String>,
|
||||
/// Get wallet balances
|
||||
#[clap(long)]
|
||||
balances: bool,
|
||||
},
|
||||
/// Get hexidecimal ID for token symbol
|
||||
Id {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to query (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token: String,
|
||||
},
|
||||
/// Withdraw Dark tokens for clear tokens
|
||||
Withdraw {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to receive (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
/// Recipient address
|
||||
#[clap(parse(try_from_str))]
|
||||
address: String,
|
||||
/// Amount to withdraw
|
||||
#[clap(parse(try_from_str))]
|
||||
amount: u64,
|
||||
},
|
||||
/// Transfer Dark tokens to address
|
||||
Transfer {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to transfer (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
/// Recipient address
|
||||
#[clap(parse(try_from_str))]
|
||||
address: String,
|
||||
/// Amount to transfer
|
||||
#[clap(parse(try_from_str))]
|
||||
amount: f64,
|
||||
},
|
||||
/// Deposit clear tokens for Dark tokens
|
||||
Deposit {
|
||||
/// Which network to use (bitcoin/solana/...)
|
||||
#[clap(long)]
|
||||
network: String,
|
||||
/// Which token to deposit (btc/sol/usdc/...)
|
||||
#[clap(parse(try_from_str))]
|
||||
token_sym: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CliDaoSubCommands {
|
||||
/// Say hello to the RPC
|
||||
Hello {},
|
||||
}
|
||||
|
||||
/// Drk cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "drk")]
|
||||
#[clap(author, version, about)]
|
||||
#[clap(global_setting(AppSettings::PropagateVersion))]
|
||||
#[clap(global_setting(AppSettings::UseLongFormatForHelpSubcommand))]
|
||||
#[clap(setting(AppSettings::SubcommandRequiredElseHelp))]
|
||||
pub struct CliDrk {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<CliDrkSubCommands>,
|
||||
}
|
||||
|
||||
/// Gatewayd cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "gatewayd")]
|
||||
pub struct CliGatewayd {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
}
|
||||
|
||||
/// Darkfid cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "darkfid")]
|
||||
pub struct CliDarkfid {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Local cashier public key
|
||||
#[clap(long)]
|
||||
pub cashier: Option<String>,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
/// Refresh the wallet and slabstore
|
||||
#[clap(short, long)]
|
||||
pub refresh: bool,
|
||||
}
|
||||
|
||||
/// Cashierd cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "cashierd")]
|
||||
pub struct CliCashierd {
|
||||
/// Sets a custom config file
|
||||
#[clap(short, long)]
|
||||
pub config: Option<String>,
|
||||
/// Get Cashier Public key
|
||||
#[clap(short, long)]
|
||||
pub address: bool,
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
/// Refresh the wallet and slabstore
|
||||
#[clap(short, long)]
|
||||
pub refresh: bool,
|
||||
}
|
||||
|
||||
/// DAO cli
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "dao")]
|
||||
pub struct CliDao {
|
||||
/// Increase verbosity
|
||||
#[clap(short, parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<CliDaoSubCommands>,
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
pub mod cli_config;
|
||||
pub mod cli_parser;
|
||||
|
||||
pub use cli_config::{CashierdConfig, Config, DarkfidConfig, DrkConfig, GatewaydConfig, MapConfig};
|
||||
|
||||
pub use cli_parser::{
|
||||
CliCashierd, CliDao, CliDaoSubCommands, CliDarkfid, CliDrk, CliDrkSubCommands, CliGatewayd,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user