ANN: OP Command Line Parser 0.9.1
Bernd Schoeller <[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
Hello everybody,
I would like to announce the release of OP, a small but powerful
library for command line parsing. To idea was to create a library that
was so easy to use that you will never want to use manual parsing
again, even for small applications with just a single or a few
options.
The main features are:
* Different types of options: flags, strings, integers, booleans ...
* Long (--make-love) and short (-l) options are supported.
* Short form can be joined (-abc instead of -a -b -c), assuming that
every one but the last is a flag (does not require an argument).
* Arguments to the short form can be added with or without space
(-ltoday or -l today).
* Arguments to the long form can be added with '=' or with a space
(--make-love=today or --make-love today)
* Option termination introduced by '--'.
* Usage instructions and a help text will be generated automatically
from the options.
* An agent can be called every time a certain option is found.
* Good default values, minimal code is required for standard
applications.
* No special 'option description language' is required. It is all just
plain Eiffel code.
The library can be downloaded at
http://se.inf.ethz.ch/people/schoeller/op.html
as a .zip or .tar.gz file. It requires current GOBO and a
GOBO-supported Eiffel compiler that knows about agents (I also have a
version of the library that works without agents that I can release if
there is a need; just tell me).
This is the first release of the library and feedback is very welcome.
Greetings,
Bernd
PS: Finally, here is some example code of how to use the library:
class
OP_EXAMPLE
create
main
feature -- Main
main is
-- Main routine
local
parser: OP_PARSER
flag: OP_FLAG
option: OP_INTEGER_OPTION
do
-- First we create the parser
create parser.make
-- We add a flag
create flag.make ('f',"flag")
flag.set_description ("A simple flag")
parser.extend (flag)
-- We add an integer option
create option.make ('o',"option")
option.set_description ("An integer option. You have to supply an"+
" integer value to this option to be parsed correctly.")
parser.extend (option)
-- We parse the arguments
parser.parse_arguments
-- Lets see what we found
if flag.was_found then
print ("The user has activated the flag.%N")
end
if option.was_found then
print ("The user has supplied the option with "+
option.value.out+"%N")
end
print ("The number of parameters were "+
parser.parameters.count.out+"%N")
end
end
To Post a message, send it to: [email protected]
To Unsubscribe, send a blank message to: [email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gobo-eiffel/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/