These are chat archives for kbknapp/clap-rs

23rd
Jan 2018
Kelly Thomas Kline
@kellytk
Jan 23 2018 05:00
Hi, is Clap suitable for implementing a terminal program akin to PostgreSQL's psql?
Kevin K.
@kbknapp
Jan 23 2018 05:03
It wasn't designed for that originally, so certain aspects may seem out of place at first, but actually works out quite nicely once you start thinking about each iteration being almost like it's own independent CLI call
It's how a few programs have implemented a daemon mode
You'll alsmost certainly want to use this setting
Kelly Thomas Kline
@kellytk
Jan 23 2018 05:06
@kbknapp Can a prompt be provided? As I'm reading through docs I'm getting the impression it's not for interactive terminals
Kevin K.
@kbknapp
Jan 23 2018 05:07
No you'd probably use a different crate to provide the prompt and just use clap to parse whatever the user passes in each time
There's a few crates out there that making providing a prompt easy
I'm not at my computer right now though so I don't have the list
Kelly Thomas Kline
@kellytk
Jan 23 2018 05:08
Thanks for your help @kbknapp
Kevin K.
@kbknapp
Jan 23 2018 05:09
No problem! If you run into any specific issues feel free to hit me up
Emil Gardström
@Emilgardis
Jan 23 2018 06:14
@kbknapp Ok, that sounds fair enough. Thank you :+1:
Casey Rodarmor
@casey
Jan 23 2018 07:30
@kbknapp I recently updated just to clap 2.29.2 (from 2.29.0) and I'm noticing that in the error message that gets printed when conflicting flags are used seems to be unstable. (The "The argument '...' cannot be used with '...' message.) The order of the flags changes, which breaks a unit test I have that checks the error message.
Did something change? Maybe a vec or btreemap to a hashmap?
This is kind of a silly test, so I'm not opposed to just scrapping it :smile:
Kevin K.
@kbknapp
Jan 23 2018 13:12
@casey ! Sorry for the regression! I'll look at it here in a few mins once I get to a computer
That's interesting
@casey can you point me to the test?
Kevin K.
@kbknapp
Jan 23 2018 13:47
Ah, yes ok I found the change. It was because I stopped storing required arguments as they come, and instead parse all the requirements at the end...which means the order is non-deterministic (although still accurate). I actually had to change one of my integration tests as well, if it's just the one test just use both variants and check against either.
For your unit tests though, if you're testing something parsed at the command line (i.e. without any processing from you), I wouldn't mind adding the test to clap (assuming it's not already being tested) so that your tests focus on just stuff and not command line parsing
Chances are good though, if it really is just command line parsing that's being tested, that it's already being tested in clap...cause the tests are pretty...encompassing :P