mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-08 14:32:24 -04:00
Make config
argument global
The `config` argument apply to all commands. It is now optional and needs to be passed before a command. E.g. `cli --config ./config.toml history`
This commit is contained in:
parent
83dcf4ba3c
commit
8fada42074
5 changed files with 73 additions and 84 deletions
|
@ -6,11 +6,11 @@ use uuid::Uuid;
|
|||
#[derive(structopt::StructOpt, Debug)]
|
||||
pub struct Arguments {
|
||||
#[structopt(
|
||||
long = "data-dir",
|
||||
help = "Provide a custom path to the data directory.",
|
||||
long = "config",
|
||||
help = "Provide a custom path to the configuration file. The configuration file must be a toml file.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
pub data_dir: Option<PathBuf>,
|
||||
pub config: Option<PathBuf>,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
pub cmd: Command,
|
||||
|
@ -31,9 +31,6 @@ pub enum Command {
|
|||
|
||||
#[structopt(long = "receive-xmr", help = "Monero amount as floating point nr without denomination (e.g. 125.1)", parse(try_from_str = parse_xmr))]
|
||||
receive_monero: monero::Amount,
|
||||
|
||||
#[structopt(flatten)]
|
||||
config: Config,
|
||||
},
|
||||
History,
|
||||
Resume(Resume),
|
||||
|
@ -52,9 +49,6 @@ pub enum Resume {
|
|||
|
||||
#[structopt(long = "counterpart-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(flatten)]
|
||||
config: Config,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -71,9 +65,6 @@ pub enum Cancel {
|
|||
#[structopt(long = "counterpart-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(flatten)]
|
||||
config: Config,
|
||||
|
||||
#[structopt(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
|
@ -92,24 +83,11 @@ pub enum Refund {
|
|||
#[structopt(long = "counterpart-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(flatten)]
|
||||
config: Config,
|
||||
|
||||
#[structopt(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(structopt::StructOpt, Debug)]
|
||||
pub struct Config {
|
||||
#[structopt(
|
||||
long = "config",
|
||||
help = "Provide a custom path to the configuration file. The configuration file must be a toml file.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
pub path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn parse_btc(str: &str) -> anyhow::Result<bitcoin::Amount> {
|
||||
let amount = bitcoin::Amount::from_str_in(str, ::bitcoin::Denomination::Bitcoin)?;
|
||||
Ok(amount)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue