01/09: Reinventing the square wheel
But I don't feel too bad because everywhere I look I see yet another bad implementation of getopt. Come on people, GNU style is cool style.
I feel like I might fix up my PHP command line options parser to conform more closely with what I'd call "expected" behavior, and support alternative syntaxes. I also half want to write my own in Bash, because everything I've found sucks in one way or another.
I think the best one I've seen so far (clean code, sensible syntax) is the getopt parser in the Python library. Even better, though, is the whole system provided by the Python optparse module. Makes me want to use Python.
Damn good documentation, here. This really explains everything there is to know about command line argument parsing:
- option
an argument used to supply extra information to guide or customize the execution of a program. There are many different syntaxes for options; the traditional Unix syntax is a hyphen (“-“) followed by a single letter, e.g. "-x" or "-F". Also, traditional Unix syntax allows multiple options to be merged into a single argument, e.g. "-x -F" is equivalent to "-xF". The GNU project introduced "--" followed by a series of hyphen-separated words, e.g."--file" or "--dry-run". These are the only two option syntaxes provided by optparse.
Some other option syntaxes that the world has seen include:
- a hyphen followed by a few letters, e.g. "-pf" (this is not the same as multiple options merged into a single argument)
- a hyphen followed by a whole word, e.g. "-file" (this is technically equivalent to the previous syntax, but they aren’t usually seen in the same program)
- a plus sign followed by a single letter, or a few letters, or a word, e.g."+f", "+rgb"
- a slash followed by a letter, or a few letters, or a word, e.g. "/f","/file"
These option syntaxes are not supported by optparse, and they never will be. This is deliberate: the first three are non-standard on any environment, and the last only makes sense if you’re exclusively targeting VMS, MS-DOS, and/or Windows.
mbt wrote:
mbt 靴 [url=http://www.mbtfan.com/]mbt 靴[/url]
mbt シューズ [url=http://www.mbtfan.com/]mbt シューズ[/url]
mbt beach [url=http://www.mbtfan.com/mbt-b...]mbt beach[/url]
mbt changa [url=http://www.mbtfan.com/mbt-c...]mbt changa[/url]
mbt chapa [url=http://www.mbtfan.com/mbt-c...]mbt chapa[/url]
mbt ema [url=http://www.mbtfan.com/mbt-e...]mbt ema[/url]
mbt fanaka [url=http://www.mbtfan.com/mbt-f...]mbt fanaka[/url]
mbt habari [url=http://www.mbtfan.com/mbt-h...]mbt habari[/url]
mbt karani [url=http://www.mbtfan.com/mbt-k...]mbt karani[/url]
mbt kaya [url=http://www.mbtfan.com/mbt-k...]mbt kaya[/url]
mbt kisumu [url=http://www.mbtfan.com/mbt-k...]mbt kisumu[/url]
mbt lami [url=http://www.mbtfan.com/mbt-l...]mbt lami[/url]
mbt m.walk [url=http://www.mbtfan.com/mbt-m...]mbt m.walk[/url]
mbt maliza [url=http://www.mbtfan.com/mbt-m...]mbt maliza[/url]
mbt panda [url=http://www.mbtfan.com/mbt-p...]mbt panda[/url]
mbt safiri [url=http://www.mbtfan.com/mbt-s...]mbt safiri[/url]
mbt salama [url=http://www.mbtfan.com/mbt-s...]mbt salama[/url]
mbt shuguli [url=http://www.mbtfan.com/mbt-s...]mbt shuguli[/url]
mbt sport [url=http://www.mbtfan.com/mbt-s...]mbt sport[/url]
mbt sport two [url=http://www.mbtfan.com/mbt-s...]mbt sport two[/url]
mbt tariki [url=http://www.mbtfan.com/mbt-t...]mbt tariki[/url]
mbt tataga [url=http://www.mbtfan.com/mbt-t...]mbt tataga[/url]
mbt tembea [url=http://www.mbtfan.com/mbt-t...]mbt tembea[/url]
mbt tunisha [url=http://www.mbtfan.com/mbt-t...]mbt tunisha[/url]
mbt voi [url=http://www.mbtfan.com/メンズ-mbt-voi-黒-p-431.html]mbt voi[/url]
mbt wingu [url=http://www.mbtfan.com/mbt-w...]mbt wingu[/url]