aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/main.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-07 15:15:38 +0000
committerDaniel Mueller <deso@posteo.net>2020-01-08 09:21:09 -0800
commit8482335491aa55b0458ffedccd1fc110f092e38a (patch)
treec6d0605ad875eb7ff8bce76b5609df988a419d44 /nitrocli/src/main.rs
parent70199fb8c1cff9323c7b60a037f3c6193bb32e29 (diff)
downloadnitrocli-8482335491aa55b0458ffedccd1fc110f092e38a.tar.gz
nitrocli-8482335491aa55b0458ffedccd1fc110f092e38a.tar.bz2
Replace argparse with structopt
This patch changes the argument handling code to use structopt instead of argparse using the data structures we introduced in the last patch. As part of that transition we replace the old Error::ArgparseError variant with ClapError that stores a structopt::clap::Error. Because of that replacement, the format of the help messages changed, breaking some of the tests. Hence, this change adapts them accordingly. Also clap currently prints the version output to stdout, so we ignore the version_option test case for now.
Diffstat (limited to 'nitrocli/src/main.rs')
-rw-r--r--nitrocli/src/main.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/nitrocli/src/main.rs b/nitrocli/src/main.rs
index c639f14..831717e 100644
--- a/nitrocli/src/main.rs
+++ b/nitrocli/src/main.rs
@@ -121,18 +121,10 @@ pub(crate) struct RunCtx<'io> {
fn run<'ctx, 'io: 'ctx>(ctx: &'ctx mut RunCtx<'io>, args: Vec<String>) -> i32 {
match args::handle_arguments(ctx, args) {
Ok(()) => 0,
- Err(err) => match err {
- Error::ArgparseError(err) => match err {
- // argparse printed the help message
- 0 => 0,
- // argparse printed an error message
- _ => 1,
- },
- _ => {
- let _ = eprintln!(ctx, "{}", err);
- 1
- }
- },
+ Err(err) => {
+ let _ = eprintln!(ctx, "{}", err);
+ 1
+ }
}
}