[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua libraries
- From: David Given <dg@...>
- Date: Sun, 16 Jan 2011 11:15:05 +0000
On 16/01/11 10:12, Axel Kittenberger wrote:
> * Its easy enough to create similar functionality with Lua code.
See line 1452 and down here:
That's the standard logic I use for all my apps. It handles short
options (-h), long options (--help), options with arguments (-ofoo and
--output foo), and non-option arguments anywhere.
The main code that makes it all work is at line 1584 and is 30 lines
long, so it's hardly worth turning into a library.
It doesn't handle --output=foo arguments and glued-together short
options (as in tar -xvzf), but could probably be made to without much
effort; I never use these, so didn't feel any urge to scratch that
The only bit of the code that's possibly not clear from reading is that
each handler function gets passed a potential option argument, and
returns 0 or 1 whether it was consumed or not.
┌─── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ───── http://www.cowlark.com ─────
│ "I have a mind like a steel trap. It's rusty and full of dead mice."
│ --- Anonymous, on rasfc
Description: OpenPGP digital signature