Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two multiple positional arguments with one being "last" are displayed in usage incorrectly if the "last" one is required #944

Closed
netvl opened this issue May 3, 2017 · 2 comments
Labels
C-bug Category: Updating dependencies
Milestone

Comments

@netvl
Copy link

netvl commented May 3, 2017

Rust Version

rustc 1.19.0-nightly (afa1240e5 2017-04-29)

Affected Version of clap

2.23.3

Expected Behavior Summary

Expected this usage text:

USAGE:
    example <FIRST>... -- <SECOND>...

Actual Behavior Summary

Got this usage text:

USAGE:
    example <FIRST>...

Steps to Reproduce the issue

Configure two positional required multiple-type arguments, with the second one being the "last". See the code below.

Also, adding an explicit AppSettings::DontCollapseArgsInUsage flag does not help.

Sample Code or Link to Sample Code

#[macro_use(clap_app)] extern crate clap;

fn main() {
    clap_app!(example =>
        (@arg FIRST: ... * "First")
        (@arg SECOND: ... * +last "Second")
    ).get_matches();
}

Curiously, if you make the second arg not required:

(@arg SECOND: ... +last "Second")

the output is correct:

USAGE:
    pwatch <FIRST>... [-- <SECOND>...]

Debug output

DEBUG:clap:Parser::propogate_settings: self=example, g_settings=AppFlags(
    NEEDS_LONG_HELP | NEEDS_LONG_VERSION | NEEDS_SC_HELP | UTF8_NONE | COLOR_AUTO
)
DEBUG:clap:Parser::get_matches_with;
DEBUG:clap:Parser::create_help_and_version;
DEBUG:clap:Parser::create_help_and_version: Building --help
DEBUG:clap:Parser::create_help_and_version: Building --version
DEBUG:clap:Parser::get_matches_with: Begin parsing '"--help"' ([45, 45, 104, 101, 108, 112])
DEBUG:clap:Parser::is_new_arg: arg="--help", Needs Val of=None
DEBUG:clap:Parser::is_new_arg: Arg::allow_leading_hyphen(false)
DEBUG:clap:Parser::is_new_arg: -- found
DEBUG:clap:Parser::is_new_arg: starts_new_arg=true
DEBUG:clap:Parser::possible_subcommand: arg="--help"
DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=None
DEBUG:clap:Parser::parse_long_arg;
DEBUG:clap:Parser::parse_long_arg: Does it contain '='...No
DEBUG:clap:Parser::parse_long_arg: Found valid flag '--help'
DEBUG:clap:Parser::check_for_help_and_version_str;
DEBUG:clap:Parser::check_for_help_and_version_str: Checking if --help is help or version...Help
DEBUG:clap:Parser::_help: use_long=true
DEBUG:clap:Parser::use_long_help: ret=false
DEBUG:clap:Help::write_parser_help;
DEBUG:clap:Help::write_parser_help;
DEBUG:clap:Parser::color;
DEBUG:clap:Parser::color: Color setting...Auto
DEBUG:clap:Help::new;
DEBUG:clap:Help::write_help;
DEBUG:clap:Help::write_default_help;
DEBUG:clap:Help::write_bin_name;
DEBUG:clap:Help::wrap_help: longest_w=7, avail_chars=190
DEBUG:clap:Help::wrap_help: Enough space to wrap...Yes
DEBUG:clap:Help::wrap_help:iter: idx=0, g=e
DEBUG:clap:Help::wrap_help:iter: idx=1, g=x
DEBUG:clap:Help::wrap_help:iter: idx=2, g=a
DEBUG:clap:Help::wrap_help:iter: idx=3, g=m
DEBUG:clap:Help::wrap_help:iter: idx=4, g=p
DEBUG:clap:Help::wrap_help:iter: idx=5, g=l
DEBUG:clap:Help::wrap_help:iter: idx=6, g=e
DEBUG:clap:Help::write_version;
DEBUG:clap:usage::create_usage_no_title;
DEBUG:clap:usage::get_required_usage_from: reqs=["FIRST", "SECOND"], extra=None
DEBUG:clap:usage::get_required_usage_from: after init desc_reqs=[]
DEBUG:clap:usage::get_required_usage_from: no more children
DEBUG:clap:usage::get_required_usage_from: final desc_reqs=["FIRST", "SECOND"]
DEBUG:clap:usage::get_required_usage_from: args_in_groups=[]
DEBUG:clap:usage::needs_flags_tag;
DEBUG:clap:usage::needs_flags_tag:iter: f=hclap_help;
DEBUG:clap:usage::needs_flags_tag:iter: f=vclap_version;
DEBUG:clap:usage::needs_flags_tag: [FLAGS] not required
DEBUG:clap:usage::create_help_usage: usage=pwatch <FIRST>...
DEBUG:clap:Help::write_all_args;
DEBUG:clap:Help::write_args;
DEBUG:clap:Help::write_args: Current Longest...2
DEBUG:clap:Help::write_args: New Longest...6
DEBUG:clap:Help::write_args: Current Longest...6
DEBUG:clap:Help::write_args: New Longest...9
DEBUG:clap:Help::write_arg;
DEBUG:clap:Help::short;
DEBUG:clap:Help::long;
DEBUG:clap:Help::val: arg=--help
DEBUG:clap:Help::spec_vals: a=--help
DEBUG:clap:Help::val: Has switch...Yes
DEBUG:clap:Help::val: force_next_line...false
DEBUG:clap:Help::val: nlh...false
DEBUG:clap:Help::val: taken...21
DEBUG:clap:Help::val: help_width > (width - taken)...23 > (190 - 21)
DEBUG:clap:Help::val: longest...9
DEBUG:clap:Help::val: next_line...No
DEBUG:clap:write_spaces!: num=7
DEBUG:clap:Help::help;
DEBUG:clap:Help::help: Next Line...false
DEBUG:clap:Help::help: Too long...No
DEBUG:clap:Help::write_arg;
DEBUG:clap:Help::short;
DEBUG:clap:Help::long;
DEBUG:clap:Help::val: arg=--version
DEBUG:clap:Help::spec_vals: a=--version
DEBUG:clap:Help::val: Has switch...Yes
DEBUG:clap:Help::val: force_next_line...false
DEBUG:clap:Help::val: nlh...false
DEBUG:clap:Help::val: taken...21
DEBUG:clap:Help::val: help_width > (width - taken)...26 > (190 - 21)
DEBUG:clap:Help::val: longest...9
DEBUG:clap:Help::val: next_line...No
DEBUG:clap:write_spaces!: num=4
DEBUG:clap:Help::help;
DEBUG:clap:Help::help: Next Line...false
DEBUG:clap:Help::help: Too long...No
DEBUG:clap:Help::write_args_unsorted;
DEBUG:clap:Help::write_arg;
DEBUG:clap:Help::short;
DEBUG:clap:Help::long;
DEBUG:clap:Help::val: arg=<FIRST>...
DEBUG:clap:Help::spec_vals: a=<FIRST>...
DEBUG:clap:Help::val: Has switch...No, and not next_line
DEBUG:clap:write_spaces!: num=5
DEBUG:clap:Help::help;
DEBUG:clap:Help::help: Next Line...false
DEBUG:clap:Help::help: Too long...No
DEBUG:clap:Help::write_arg;
DEBUG:clap:Help::short;
DEBUG:clap:Help::long;
DEBUG:clap:Help::val: arg=<SECOND>...
DEBUG:clap:Help::spec_vals: a=<SECOND>...
DEBUG:clap:Help::val: Has switch...No, and not next_line
DEBUG:clap:write_spaces!: num=4
DEBUG:clap:Help::help;
DEBUG:clap:Help::help: Next Line...false
DEBUG:clap:Help::help: Too long...No
@kbknapp
Copy link
Member

kbknapp commented May 5, 2017

Interesting, thanks for taking the time to file this!

@kbknapp kbknapp added C: usage strings C-bug Category: Updating dependencies labels May 5, 2017
@kbknapp kbknapp added this to the 2.24.1 milestone May 6, 2017
kbknapp added a commit that referenced this issue May 7, 2017
…re not being printed in the usage string

Closes #944
@kbknapp kbknapp closed this as completed in 9f9364b May 7, 2017
@kbknapp
Copy link
Member

kbknapp commented May 7, 2017

2.24.1 is on crates.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants