These are chat archives for kbknapp/clap-rs

14th
May 2017
xd009642
@xd009642
May 14 2017 14:18
So two hopefully easy questions. How does clap handle enum tuples? And I take it arg_enum! won't work with an enum from an external crate?
I have an enum in an external crate and the last field is Other(String), none of the other fields have values though
Kevin K.
@kbknapp
May 14 2017 14:21
If the enum is from another crate it can only be used if FromStr gets implemented for it
xd009642
@xd009642
May 14 2017 14:21
That makes sense, what about the enum tuples?
Kevin K.
@kbknapp
May 14 2017 14:22
Unfortunately, arg_enum! can't be used in that case because the enum is already defined and that macro only works with enum definitions
I'd need to see an example for what you're trying to do with enum tuples
Do you mean where the variants of the enum are tuples or a tuple or two distinct enums?
xd009642
@xd009642
May 14 2017 14:23
Okay so the enum in question looks like this:
enum SourceControl{ Git, Svn, Mercurial, Other(String)}
Though if I implement FromStr I imagine that can solve that as well? Just have the default go into Other()
Kevin K.
@kbknapp
May 14 2017 14:26
Exactly
Shouod be very easy
xd009642
@xd009642
May 14 2017 14:27
Yeah, thanks @kbknapp :)
Kevin K.
@kbknapp
May 14 2017 14:27
No problem!