From: William Morgan Date: 2010-05-12T11:44:12+09:00 Subject: Re: interested in writing a commandline option parser for ruby? Reformatted excerpts from Michael Fellinger's message of 2010-05-11: > I have no idea what caused this rage of you, Suboptimal software. > but would you kindly tell me what's wrong with OptionParser > (optparse.rb in stdlib)? 1. Too many positional arguments. Which is the correct version? opts.on( '-f', '--float NUM', Float, "Convert to float" ) opts.on( '-f', '--float NUM', "Convert to float", Float ) If you have to look it up, optparse fails. 2. The use of blocks. 99% of the time you're just throwing stuff in a hash anyways, in which case you now have to maintain the mapping between hash keys and arguments. The rest of the time you're doing complicated stuff in the blocks, in which case you have code mixed in the middle of your argument list. 3. No notion of default arguments. You have to explicitly write them into your code, e.g. by using a hash and initializing it. 4. If optparse knows your argument is named '--float', why doesn't it automatically generate a short option '-f'? (Likewise, if optparse knew what your default value was, it could infer the type-checking for you.) 5. Complicated API. on_head, on_tail, make_switch, etc. 6. I like for my help pages to be wrapped nicely, e.g. Options: --delete, -d: Delete everything --restore, -r: Restore everything. Of course this doesn't actually work. What's gone is gone. But it might make the user feel hopeful for a second, and, after all, isn't that valuable in and of itself? (default: true) --help, -h: Show this message Optparse just makes a big blob. That's all I can think of now... -- William