Optional values
Currently there's no way to mark a ValueT as optional and the only possible workaround to this is to use a OptionT with a val field which limits the ergonomics on the CLI side. Having optional values can allow certain values to be passed directly without any prefix option.
@AMythicDev You can accomplish this using the vals_mandatory field of a single Command, or the global_vals_mandatory in your Command Config for all Commands.
The limitation here is that the Values still need to be provided in order. So if you have two Values on a Command, like an integer and a string, you can do all of these:
cmd
cmd 10
cmd 10 "some string"
But you can not do:
cmd "some string"
Let me know if that works for you or if you have any other questions. Thanks for trying Cova!
Thanks, the vals_mandatory option did the trick. However I was wondering if we could do this on per value basis rather than for all values in a command. Like in a command I want some values to be required and some values to be optional.
We can enforce that all the required value fields to be the last in value order and will always be matched. If they don't match, we raise an error. For optional values, they must be present before all required values and they are matched after all required values are matched.
Let me know if you are interested in it and feel free to hit me if you want any help.
Thanks again for the speedy response.
That's doable, but it'd be a somewhat heavy change to the Value parsing. If I do implement it, I'll likely go with Mandatory Values first. Let me think about it a bit.
In the interim, you could try sequentially looking for your required Values immediately after calling cova.parse(). That could be done in just a few lines pretty easily. I can put together an example a little later if you'd like.
Thanks for looking into it. Will be happy to see it getting implemented.
Hii. Did you start working on this? Is there a PR/branch that I should look out for?
Thanks
@AMythicDev
Not yet. I'm deeply focused on another project at the moment and haven't had a chance to see if I like the way it'll fit in.
In the meantime, I'd recommend making your Values not mandatory, then immediately checking for the Values you need after parsing. You can use val.argIdx() to help with ordering as well.