Skip to content

Help with Arg::New -- second arg being required when I don't want it to be #5861

Answered by epage
andrewschott asked this question in Q&A
Discussion options

You must be logged in to vote

This is an ambitious situation in the parser. Unless we check the parse result and rely on the user correctly typing answers for the first parameter, there is no clear way to say whether the last argument is part of the first Arg or the second.

We don't check the parse result for a couple of reasons

  • Historical
  • Error messages
  • That can still be ambiguous
  • Some users are sensitive to what clap over-parsing

I wouldn't have been able to say what we do in this situation because the nuance involved in that part of the code. If we didn't have the logic to assume the user meant the last positional, the alternative would likely have been an assert since then we could never reach the last argument.

A…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@andrewschott
Comment options

@epage
Comment options

Answer selected by andrewschott
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants