diff --git a/taptrade-cli-demo/src/cli/mod.rs b/taptrade-cli-demo/src/cli/mod.rs new file mode 100644 index 0000000..eca9c8d --- /dev/null +++ b/taptrade-cli-demo/src/cli/mod.rs @@ -0,0 +1,50 @@ +use clap::{command, Arg, Command, ArgMatches}; + +use crate::coordinator; + +pub struct cli_settings { + pub coordinator: bool, + pub maker: bool, + pub taker: bool, + pub c_endpoint: String, + pub electrum_ep: String, +} + +trait ArgMatchesParser { + +} + +pub fn parse_cli_args() -> ArgMatches { + command!() + .about("RoboSats taproot onchain trade pipeline CLI demonstrator. Don't use with real funds.") + .subcommand( + Command::new("coordinator") + ) + .subcommand( + Command::new("trader") + .arg( + Arg::new("taker") + .short('t') + .long("taker") + .help("Run program as taker") + .num_args(0) + .conflicts_with("maker") + ) + .arg ( + Arg::new("maker") + .short('m') + .long("maker") + .num_args(0) + .help("Run program as maker") + .conflicts_with("taker") + ) + .arg( + Arg::new("endpoint") + .short('p') + .long("endpoint") + .required(true) + .help("Communication endpoint of the coordinator to connect to") + ) + ) + .get_matches() +} diff --git a/taptrade-cli-demo/src/main.rs b/taptrade-cli-demo/src/main.rs index c4ba3b0..230f7ee 100644 --- a/taptrade-cli-demo/src/main.rs +++ b/taptrade-cli-demo/src/main.rs @@ -1,27 +1,13 @@ -use clap::{command, Arg}; mod trader; mod coordinator; +mod cli; + +use cli::parse_cli_args; fn main() { - let cli_args = command!() - .about("RoboSats taproot onchain trade pipeline CLI demonstrator. Don't use with real funds.") - .arg( - Arg::new("mode") - .short('m') - .long("mode") - .required(true) - .help("Mode: coordinator, maker or taker")) - .arg( - Arg::new("endpoint") - .short('p') - .long("endpoint") - .help("Communication endpoint of the coordinator to connect to") - // .conflicts_with("coordinator") - ) // only required for traders - .get_matches(); + let cli_args = parse_cli_args(); } // use clap to parse mode (taker, maker or coordinator), communication endpoint (URL or PID or something else), electrum server // https://www.youtube.com/watch?v=Ot3qCA3Iv_8 -// clap tutorial (min 32)