This commit is contained in:
fbock
2024-05-29 09:03:11 +00:00
parent 597c28e1ef
commit 9c57b87b4e
2 changed files with 54 additions and 18 deletions

View File

@ -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()
}

View File

@ -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)