From 9f9364b1d861f1b0eebedd1a230e54485b8ca474 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sat, 6 May 2017 20:18:21 -0400 Subject: [PATCH] fix: fixes a bug where args with last(true) and required(true) set were not being printed in the usage string Closes #944 --- src/app/usage.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/usage.rs b/src/app/usage.rs index a3b7a96c..5fde641e 100644 --- a/src/app/usage.rs +++ b/src/app/usage.rs @@ -100,7 +100,7 @@ pub fn create_help_usage(p: &Parser, incl_reqs: bool) -> String { usage.push_str(" [--]"); } let not_req_or_hidden = - |p: &PosBuilder| !p.is_set(ArgSettings::Required) && !p.is_set(ArgSettings::Hidden); + |p: &PosBuilder| (!p.is_set(ArgSettings::Required) || p.is_set(ArgSettings::Last)) && !p.is_set(ArgSettings::Hidden); if p.has_positionals() && p.positionals.values().any(not_req_or_hidden) { if let Some(args_tag) = get_args_tag(p, incl_reqs) { usage.push_str(&*args_tag); @@ -114,8 +114,10 @@ pub fn create_help_usage(p: &Parser, incl_reqs: bool) -> String { .expect(INTERNAL_ERROR_MSG); debugln!("usage::create_help_usage: '{}' has .last(true)", pos.name()); let req = pos.is_set(ArgSettings::Required); - if req { + if req && p.positionals.values().any(|p| !p.is_set(ArgSettings::Required)) { usage.push_str(" -- <"); + } else if req { + usage.push_str(" [--] <"); } else { usage.push_str(" [-- <"); }