mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-23 11:13:17 +00:00
parsing
This commit is contained in:
50
taptrade-cli-demo/src/cli/mod.rs
Normal file
50
taptrade-cli-demo/src/cli/mod.rs
Normal 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()
|
||||||
|
}
|
@ -1,27 +1,13 @@
|
|||||||
use clap::{command, Arg};
|
|
||||||
mod trader;
|
mod trader;
|
||||||
mod coordinator;
|
mod coordinator;
|
||||||
|
mod cli;
|
||||||
|
|
||||||
|
use cli::parse_cli_args;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli_args = command!()
|
let cli_args = parse_cli_args();
|
||||||
.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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// use clap to parse mode (taker, maker or coordinator), communication endpoint (URL or PID or something else), electrum server
|
// 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
|
// https://www.youtube.com/watch?v=Ot3qCA3Iv_8
|
||||||
// clap tutorial (min 32)
|
|
||||||
|
Reference in New Issue
Block a user