mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Merge #519
519: Avoid application error upon `--help` r=da-kami a=da-kami Our `preview` release is currently broken because of this issue. The way we use clap's `get_matches_from_safe` caused parsing errors upon `--help` and `--version` to be bubbled up to the application - which causes the application to exit with an error when running `--help` and `--version`. This is solved by using `get_matches_from` instead of `get_matches_from_safe` which handles these known clap commands internally and exits early. Added smoke tests to CI so we catch such kind of problems in the future. Smoke testing by calling `--help` is cheap and should be OK in CI. Co-authored-by: Daniel Karzel <daniel@comit.network>
This commit is contained in:
commit
ba33e1acc1
@ -20,6 +20,8 @@ use std::future::Future;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use structopt::clap;
|
||||||
|
use structopt::clap::ErrorKind;
|
||||||
use swap::bitcoin::TxLock;
|
use swap::bitcoin::TxLock;
|
||||||
use swap::cli::command::{parse_args_and_apply_defaults, Arguments, Command};
|
use swap::cli::command::{parse_args_and_apply_defaults, Arguments, Command};
|
||||||
use swap::database::Database;
|
use swap::database::Database;
|
||||||
@ -44,7 +46,23 @@ async fn main() -> Result<()> {
|
|||||||
data_dir,
|
data_dir,
|
||||||
debug,
|
debug,
|
||||||
cmd,
|
cmd,
|
||||||
} = parse_args_and_apply_defaults(env::args_os())?;
|
} = match parse_args_and_apply_defaults(env::args_os()) {
|
||||||
|
Ok(args) => args,
|
||||||
|
Err(e) => {
|
||||||
|
if let Some(clap_err) = e.downcast_ref::<clap::Error>() {
|
||||||
|
match clap_err.kind {
|
||||||
|
ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => {
|
||||||
|
println!("{}", clap_err.message);
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
bail!(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bail!(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
match cmd {
|
match cmd {
|
||||||
Command::BuyXmr {
|
Command::BuyXmr {
|
||||||
|
Loading…
Reference in New Issue
Block a user