Download
(11 Kb)
Download
Updated: 02-24-13 09:01 PM
Updated:02-24-13 09:01 PM
Created:10-12-11 07:04 PM
Downloads:94
Favorites:1
MD5:
LibGetOpt
Version: 0.12
by: seebs [More]
LibGetOpt is a preliminary draft of an addon to do, well, exactly what the name suggests: Parse options in a format that will be familiar to Unix users everywhere.

Example usage:

Library.LibGetOpt("a:b", "-a foo -b bar baz")

This would yield a table

{
"a" => "foo"
"b" => true
"leftover" => "bar baz"
"leftover_args" => { "bar" "baz" }
}

It can also register a slash command for you such that your function gets called with such a table instead of a string.

The intent is that this will allow addon developers to add simple flag options to their slash commands without having to reinvent that particular wheel.

The only thing you can do with this without adding it to another addon is "/getopt -d 2" to set debugging on... You can also pass other words to it to see how the quoting works.

I finally fixed the quoting so it handles backslashes and quotes in the middle of words and everything else correctly. Want that? Library.LibGetOpt.dequote(string) yields a table of the words in string, respecting quoting conventions.
0.9:
* Various fixes
* Support for multiply-specified options
0.10:
* TOC update.

0.11:
* ToC update
* change way printf is used

0.12:
* Make leftover_full available for the full text (including quotes and backslashes) of any unused material.
Optional Files (0)


Archived Files (5)
File Name
Version
Size
Author
Date
0.11
10kB
seebs
11-03-12 01:43 AM
0.10
7kB
seebs
06-22-12 09:48 PM
0.9
7kB
seebs
03-16-12 01:06 PM
0.5
5kB
seebs
10-12-11 10:23 PM
0.4
4kB
seebs
10-12-11 07:04 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: