Skip to content

Commit

Permalink
Allow nesting of '--'
Browse files Browse the repository at this point in the history
Suppose there is a program that executes another program, then it is
convenient to take the arguments of the subprogram after `--`, as
illustrated in the 22_stop_parsing_with_--.rs example. However, if
the subprogram itself wants to receive `--`, then clap-rs should
allow it.

Fixes #1161.
  • Loading branch information
da-x committed Feb 3, 2018
1 parent d29100f commit 73993fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,9 @@ where
self.unset(AS::ValidNegNumFound);
// Is this a new argument, or values from a previous option?
let starts_new_arg = self.is_new_arg(&arg_os, needs_val_of);
if arg_os.starts_with(b"--") && arg_os.len_() == 2 && starts_new_arg {
if !self.is_set(AS::TrailingValues) &&
arg_os.starts_with(b"--") && arg_os.len_() == 2 && starts_new_arg
{
debugln!("Parser::get_matches_with: setting TrailingVals=true");
self.set(AS::TrailingValues);
continue;
Expand Down

0 comments on commit 73993fe

Please sign in to comment.