summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-02-16 18:40:43 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-02-16 19:41:30 +0100
commit9eadce68d85a741bd188816a582feef30446415c (patch)
tree4249394937cb2d21d6217bf7e283bae35290457e
parent0ca4582b07681993b720b684a80ff2e2498463bc (diff)
downloadnitrocli-topic/test-version-flag.tar.gz
nitrocli-topic/test-version-flag.tar.bz2
fixup! Manually handle -V/--version argumenttopic/test-version-flag
-rw-r--r--nitrocli/src/args.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index 33069e6..6d77894 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -864,25 +864,28 @@ pub(crate) fn handle_arguments(ctx: &mut RunCtx<'_>, args: Vec<String>) -> Resul
"The arguments for the command",
);
parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {}", command));
+ let result = parse(ctx, parser, args);
if version {
ctx.stdout.write_all(concat!("nitrocli ", env!("CARGO_PKG_VERSION")).as_ref())?;
Ok(())
} else {
- let mut ctx = ExecCtx {
- model,
- stdout: ctx.stdout,
- stderr: ctx.stderr,
- admin_pin: ctx.admin_pin.take(),
- user_pin: ctx.user_pin.take(),
- new_admin_pin: ctx.new_admin_pin.take(),
- new_user_pin: ctx.new_user_pin.take(),
- password: ctx.password.take(),
- verbosity,
- };
- command.execute(&mut ctx, subargs)
+ if result.is_ok() {
+ subargs.insert(0, format!("nitrocli {}", command));
+ let mut ctx = ExecCtx {
+ model,
+ stdout: ctx.stdout,
+ stderr: ctx.stderr,
+ admin_pin: ctx.admin_pin.take(),
+ user_pin: ctx.user_pin.take(),
+ new_admin_pin: ctx.new_admin_pin.take(),
+ new_user_pin: ctx.new_user_pin.take(),
+ password: ctx.password.take(),
+ verbosity,
+ };
+ command.execute(&mut ctx, subargs)
+ } else {
+ result
+ }
}
}