catchorg / Clara

A simple to use, composable, command line parser for C++ 11 and beyond

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.required() on Parsers doesn't make them fail the parse

bearcage opened this issue · comments

I'm guessing this is just not written yet, since the spot where it'd go at the end of parse() has a // !TBD about it. It doesn't look like there's a super clean place to expose required/not to users of the API, since there's no magic operator()/operator[] left open for it, in contrast with descriptions/flags (unless you want to get cute with overloading), but even just correct behavior with the somewhat-less-pretty .required() would work for me.

If you've got an approach in mind, I'd be happy to take a whack at it since it looks like it won't take too much to do.

cc @TheOnlyRew

Oh, hey, looks like #28 is already addressing this, so I'll just leave the issue here for now. If either of you need a hand with this just let me know.

Also just bumped into this, and #28 seems to have been hanging there for a while now.

Was it fixed?
I'm using v1.1.5 and it still doesn't fail on a non-give required() Arg|Opt

Update: checked master and it still reproduces

So #28 got replaced, apparently, with another patch that didn't actually do this?

+1 this is super confusing...I made an Arg required and apart from the help updating, it didn't actually make it required :)

If it's any consolation .required() is now actually required in Lyra thanks to this PR bfgroup/Lyra@8d6f122

Can that commit just be ported over to this repo and submitted as a PR?

(There's #94 but it seems less nice than this one.)

Hmm. Doesn't solve the "this is used in catch2" problem though.

I don't see where required() is used in catch2. So why is it a problem?

Because I'm working on a test suite with a custom main function in catch2, and I'm trying to do what is recommended there and use Clara to parse my custom arguments. I do have required arguments.