From c1f35ab538dbdf3002a6a9aa0932ada687160787 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 7 Jan 2020 15:15:38 +0000 Subject: 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. --- src/main.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index c639f14..831717e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,18 +121,10 @@ pub(crate) struct RunCtx<'io> { fn run<'ctx, 'io: 'ctx>(ctx: &'ctx mut RunCtx<'io>, args: Vec) -> 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 + } } } -- cgit v1.2.1