These are chat archives for kbknapp/clap-rs

18th
Aug 2017
Kevin K.
@kbknapp
Aug 18 2017 14:06
:+1:
Casey Rodarmor
@casey
Aug 18 2017 20:06
@kbknapp Sweet, one of those looks like it'll work. Thanks!
Jeroen Bollen
@Binero
Aug 18 2017 20:14
My only grievance with this library so far is that you cannot associate a type with a parameter, like file, integer, basic string, any string, etc.
Other than that it's great though, I can't imagine ever writing such a flexible cli tool without this crate in just two days.
Kevin K.
@kbknapp
Aug 18 2017 20:26
@Binero thanks! It's on the tracker to add support for types in v3. So stay tuned ;)
@casey does just support an optional parameter?
Casey Rodarmor
@casey
Aug 18 2017 20:33
@kbknapp Sort of, you can give a parameter a default value, like recipe parameter='', which allows it not to be specified on the command line.
More clearly: recipe parameter='': ...
Kevin K.
@kbknapp
Aug 18 2017 20:33
Perfect thanks!
Jeroen Bollen
@Binero
Aug 18 2017 20:38
@kbknapp Do you know what issue that is? I tried to search for it, but couldn't find it.
Casey Rodarmor
@casey
Aug 18 2017 20:42
@kbknapp ^__^
Kevin K.
@kbknapp
Aug 18 2017 20:42
There isn't a dedicated one, as much of the V3 work has been happening locally in my off time. It's loosely grouped in with the CustomDerive work
Jeroen Bollen
@Binero
Aug 18 2017 20:43
Aha, iirc that's the issue with the massive checklist
Kevin K.
@kbknapp
Aug 18 2017 20:43
If you'd like to open one just for tracking, that's fine with me ;)
Jeroen Bollen
@Binero
Aug 18 2017 20:50
kbknapp/clap-rs#1032
Kevin K.
@kbknapp
Aug 18 2017 21:00
:+1: thanks!
Jeroen Bollen
@Binero
Aug 18 2017 21:37
How would I make it so the --page-size parameter is only allowed when either the --boot-file parameter, the --kernel-file parameter, or both are set?
e.g.
yes: bootimage --page-size 2048 --kernel-image './kernel.img'
yes: bootimage --page-size 2048 --boot-image './boot.img'
no: bootimage --page-size 2048
Kevin K.
@kbknapp
Aug 18 2017 22:01
Arg::requires_all
On the --page-size arg
Jeroen Bollen
@Binero
Aug 18 2017 22:04
@kbknapp Going from the docs that'd require both?
Kevin K.
@kbknapp
Aug 18 2017 22:04
Or just Arg::requires
Jeroen Bollen
@Binero
Aug 18 2017 22:05
@kbknapp But that'd require just one. :)
@kbknapp I am looking for something like requires_one_of.
Kevin K.
@kbknapp
Aug 18 2017 22:05
Yeah that was my mistake, I misread it
Jeroen Bollen
@Binero
Aug 18 2017 22:06

I took peace with adding the following to the help:

This parameter does nothing when boot image or kernel image have been passed.

Oh, good thing I put this in gitter because I just realised it is missing a no. :)
Never mind, copy pasting it dropped the no in the middle somehow...
Kevin K.
@kbknapp
Aug 18 2017 22:07
"Requires one of" is possible with ArgGroups
And was the original purpose of them
You add those two args to a group, and say --page-size requires that group
Jeroen Bollen
@Binero
Aug 18 2017 22:12
that might work, but it'd make for a very, uhm, 'interesting' way to group arguments.
Kevin K.
@kbknapp
Aug 18 2017 22:14
Perhaps, but in this case it's a single purpose group that shouldn't affect anything (other than allowing this requirement rule)
I'm on mobile now though, or I'd do a quick example
Jeroen Bollen
@Binero
Aug 18 2017 22:17
The example in the doc is plenty, so no worries
I'd much rather use the ArgGroup for making sure the user supplies at least one input file though.
Jeroen Bollen
@Binero
Aug 18 2017 22:28
Ohh I see, I thought arg groups took ownership of the arguments
My bad
Is there a way to make the arg group require one, but allow more?
Kevin K.
@kbknapp
Aug 18 2017 22:34
I thought so, but I'd have to test it since it's been a while since I've messed with them. Im almost positive there was a way to do require at least one...but if not that's a feature gap I need to add
Ah yeah, do ::multiple(true)
ArgGroup
Sorry, took me a minute to remember
(I'm not sure why this mobile app keeps sending the struct name in the message after the method name :P)
Jeroen Bollen
@Binero
Aug 18 2017 22:50
Ah crap that one should have been obvious, sorry. I was too focussed on looking for required :s