These are chat archives for kbknapp/clap-rs

15th
Jul 2015
Severen Redwood
@severen
Jul 15 2015 02:46
Is it possible to make it so that the option -V, --version is disabled for subcommands that haven't defined a version, or at least inherit the version of the parent command?
Kevin K.
@kbknapp
Jul 15 2015 03:06
Hmmm, I hadn't thought about that. It's possible to get the same effect manually in a couple different ways, but admittedly none are super ergonomic. Let me think about this for a day and see what I can come up with.
Kevin K.
@kbknapp
Jul 15 2015 03:13
Since it's already possible to propagate arguments down through subcommands it would be an easy thing to add App::global_version(true) which may be what direction I end up taking. At the same time, it's probably one of those issues which isn't a huge issue in practice. For instance, I don't know many people that do a program subcommand --version expecting the program version (or they'd just do program --version.
Kevin K.
@kbknapp
Jul 15 2015 03:19
This message was deleted
Just for completeness the current "work-arounds" are:
  • Create an argument that has a long of --version and sets global(true), but then you have to manually check matches.is_present("version") and handle it accordingly.
  • Manually set version(&*crate_version!()) on each subcommand to automatically get the crate version (may only be an option if you only have a few subcommands)
Severen Redwood
@severen
Jul 15 2015 03:26
In your typical git-like CLI you don't have different versions for the subcommands, so having the --version options removed for subcommands that don't have their own version defined is imo the best option.
Kevin K.
@kbknapp
Jul 15 2015 03:31
That's a good point. There are also some cargo-like CLIs where each subcommand is/can be a separate "program" in and of itself, which is main reason for having the option of a separate version. But I do agree, that is the exception and not the rule. Also, it's well documented, but in subcomamnds (or even top level program), defining an argument with a short of -V is totally possible, and simply removes it from --version.
I think what I'll do is add App::versionless_subcommands(bool) and App::global_version(bool) in order to allow both methodologies
Severen Redwood
@severen
Jul 15 2015 03:34
Just a note, I'd hack around with the code myself, however my Rust knowledge is pretty crap so I'd have a hard time writing proper code or even just understanding the code myself.
Kevin K.
@kbknapp
Jul 15 2015 03:34
In all honesty, after seeing it, I'd sort of like to make versionless subcommands the default (Opt-In to version'ed subcommands), but it may be alittle late for that :P
Severen Redwood
@severen
Jul 15 2015 03:34
Haha
Kevin K.
@kbknapp
Jul 15 2015 03:35
No worries! Just taking the time to mention the issue here is a huge help and much appreciated! :+1:
Severen Redwood
@severen
Jul 15 2015 03:35
I'm probably going to go off and read all of the Rust book + Rust by Example.
In an attempt to actually properly learn Rust
Kevin K.
@kbknapp
Jul 15 2015 03:36
Rust Book is a really good read, Rust by Example is also good but sometimes hard to follow unless you're already familiar with Rust
Severen Redwood
@severen
Jul 15 2015 03:36
Okay, do you know of any other good Rust resources?
Kevin K.
@kbknapp
Jul 15 2015 03:36
There is an "awesome-list" like list about resources for learning Rust...but I don't remember the link at the moment
Severen Redwood
@severen
Jul 15 2015 03:37
Google to the rescue ;)
Severen Redwood
@severen
Jul 15 2015 03:37
Oh, thanks :)
Kevin K.
@kbknapp
Jul 15 2015 03:38
This message was deleted
This message was deleted
No prob!
I've got some videos up about using clap, but they're getting quite old and I've been in the process of updating them forever. All the content still works, but it's missing a ton of the newer features. And that's also geared more towards clap specific and not really learning Rust
Severen Redwood
@severen
Jul 15 2015 03:40
I've watched a few of those videos, they were quite helpful :)
I love what you're doing with Clap in general though (although I slightly dislike the default help formatting :P) and I can't wait until I can contribute some proper code.
Kevin K.
@kbknapp
Jul 15 2015 03:46
Perhaps I'll add an option to group all "options" in the help message at some point too ;)
Any contributions are always welcome! And in fact, the no-kidding best way to learn Rust is jump in. The clap source is kind of a mess, but at least grouped somewhat decently. So if you find a feature you want to hack on, go for it! And if you get it working, put in a PR. Actually even if you almost get it working put in a PR and I can try and help sort it out or guide it
Kevin K.
@kbknapp
Jul 15 2015 03:52
Keep an eye out for #156, #157, and #158 (although #158 is still a maybe :P)!
Severen Redwood
@severen
Jul 15 2015 03:56
Oh by the way I'm a male haha, just noticed you called me 'them' ;)
Kevin K.
@kbknapp
Jul 15 2015 03:56
I figured...but I figured why risk it :P
Severen Redwood
@severen
Jul 15 2015 03:58
Haha, who knows with all of the different genders these days (51 gender options on Facebook holy crap)
Kevin K.
@kbknapp
Jul 15 2015 04:07
no kidding!
Severen Redwood
@severen
Jul 15 2015 04:18
yep
Severen Redwood
@severen
Jul 15 2015 07:53

I made a Gist with a bunch of ideas I have: https://gist.github.com/SShrike/9256bcf7807d4d0b1f7a

It's incomplete since I still have a few ideas to type out. Also, sorry for the sloppy writing. (I'd pulled an all-nighter the night before, so naturally since it is 7:53 PM over here I'm starting to feel pretty tired)

If anything seems unclear just ask me for clarification :)
Kevin K.
@kbknapp
Jul 15 2015 09:52
Wiil do thanks!