On 20/04/14 10:44 +0200, Geoffroy Couprie wrote:
Hi,I encountered the same problem, and I wound up writing a library to solve it (instead of working on my original code): https://github.com/Geal/typedopts The basic idea is to define a Decoder that can work on command line options. Then you just need to add "#[deriving(Decodable)]" to a structure that represents your command line options, and the matching will be safe and easy. I chose to make the Decoder work on the results of getopts, but it is possible to work directly on os::args. There is another library that does the same thing here: https://github.com/wycats/hammer.rs
Cheers, Geoffroy
Thanks for the tips! So neither seems to solve my issue at face value. I'm just going through and fixing some ~[T] and ~str -> StrBuf issues in hammer at the moment so I can play with it (PR incoming, if you're subbed wycats). My underlying issue is a bit more "Why can't I do this totally plausible looking thing", albeit wrapped strongly in the "Pattern matching on args is a generally useful thing" context. I'll fiddle with both of these and see if I can get them to work for me. Thanks again!
pgpW9JuQuD6xd.pgp
Description: PGP signature
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
