You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that in the last case, value should be Some(",").
Sample Code or Link to Sample Code
externcrate clap;use clap::{App,Arg};fnmain(){let m = App::new("foo").arg(Arg::with_name("delimiter").short("d").long("delimiter").takes_value(true).require_equals(true).min_values(0).default_value(","),).get_matches();println!("occurs: {}", m.occurrences_of("delimiter"));println!("value: {:?}", m.value_of("delimiter"));}
Debug output
For the -d case:
DEBUG:clap:Parser::propogate_settings: self=time, 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 --helpDEBUG:clap:Parser::create_help_and_version: Building --versionDEBUG:clap:Parser::get_matches_with: Begin parsing '"-d"' ([45, 100])DEBUG:clap:Parser::is_new_arg: arg="-d", Needs Val of=NotFoundDEBUG:clap:Parser::is_new_arg: Arg::allow_leading_hyphen(false)DEBUG:clap:Parser::is_new_arg: - foundDEBUG:clap:Parser::is_new_arg: starts_new_arg=trueDEBUG:clap:Parser::possible_subcommand: arg="-d"DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=NoneDEBUG:clap:Parser::parse_short_arg: full_arg="-d"DEBUG:clap:Parser::parse_short_arg:iter:dDEBUG:clap:Parser::parse_short_arg:iter:d: Found valid optDEBUG:clap:Parser::parse_short_arg:iter:d: p[0]=[], p[1]=[]DEBUG:clap:Parser::parse_opt; opt=delimiter, val=NoneDEBUG:clap:Parser::parse_opt; opt.settings=ArgFlags(TAKES_VAL | DELIM_NOT_SET | REQUIRE_EQUALS)DEBUG:clap:Parser::parse_opt; Checking for val...NoneDEBUG:clap:ArgMatcher::inc_occurrence_of: arg=delimiterDEBUG:clap:ArgMatcher::inc_occurrence_of: first instanceDEBUG:clap:Parser::groups_for_arg: name=delimiterDEBUG:clap:Parser::groups_for_arg: No groups definedDEBUG:clap:Parser::parse_opt: More arg vals not required...DEBUG:clap:arg_post_processing!;DEBUG:clap:OptBuilder::fmt:delimiterDEBUG:clap:arg_post_processing!: Is '--delimiter=<delimiter>' in overrides...NoDEBUG:clap:OptBuilder::fmt:delimiterDEBUG:clap:arg_post_processing!: Does '--delimiter=<delimiter>' have overrides...NoDEBUG:clap:OptBuilder::fmt:delimiterDEBUG:clap:arg_post_processing!: Does '--delimiter=<delimiter>' have conflicts...NoDEBUG:clap:OptBuilder::fmt:delimiterDEBUG:clap:arg_post_processing!: Does '--delimiter=<delimiter>' have requirements...NoDEBUG:clap:_handle_group_reqs!;DEBUG:clap:Parser:get_matches_with: After parse_short_arg ValuesDoneDEBUG:clap:Validator::validate;DEBUG:clap:Validator::validate_blacklist: blacklist=[]DEBUG:clap:Validator::validate_required: required=[];DEBUG:clap:Validator::validate_matched_args;DEBUG:clap:Validator::validate_matched_args:iter:delimiter: vals=[]DEBUG:clap:Validator::validate_arg_num_vals;DEBUG:clap:Validator::validate_arg_num_vals: min_vals set: 0DEBUG:clap:Validator::validate_values: arg="delimiter"DEBUG:clap:Validator::validate_arg_requires;DEBUG:clap:Validator::validate_arg_num_occurs: a=delimiter;DEBUG:clap:usage::create_usage_with_title;DEBUG:clap:usage::create_usage_no_title;DEBUG:clap:usage::get_required_usage_from: reqs=[], extra=NoneDEBUG:clap:usage::get_required_usage_from: after init desc_reqs=[]DEBUG:clap:usage::get_required_usage_from: no more childrenDEBUG:clap:usage::get_required_usage_from: final desc_reqs=[]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 requiredDEBUG:clap:usage::create_help_usage: usage=x [OPTIONS]
The text was updated successfully, but these errors were encountered:
Rust Version
rustc 1.22.0-nightly (ddd123ed9 2017-09-09)
Affected Version of clap
2.26.1
Expected Behavior Summary
When a
require_equals
+min_values(0)
argument is given on the command line without a value, the default value should be set as its value in matches.Actual Behavior Summary
If the argument is given without a value,
occurs
is 1, butvals
is[]
.Steps to Reproduce the issue
Using the code below, try the following command lines:
Notice that in the last case,
value
should beSome(",")
.Sample Code or Link to Sample Code
Debug output
For the
-d
case:The text was updated successfully, but these errors were encountered: