ANNOUNCE: Optik 1.3 released
Greg Ward
gward@python.net
Thu, 11 Apr 2002 15:34:38 -0400
Optik 1.3
=========
Optik is a powerful, flexible, extensible, easy-to-use command-line
parsing library for Python. Using Optik, you can add intelligent,
sophisticated handling of command-line options to your scripts with very
little overhead.
Here's an example of using Optik to add some command-line options to a
simple script:
from optik import OptionParser
[...]
parser = OptionParser()
parser.add_option("-f", "--file",
action="store", type="string", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=1,
help="don't print status messages to stdout")
(options, args) = parser.parse_args()
With these few lines of code, users of your script can now do the
"usual thing" on the command-line:
<yourscript> -f outfile --quiet
<yourscript> -qfoutfile
<yourscript> --file=outfile -q
<yourscript> --quiet --file outfile
(All of these result in
options.filename == "outfile"
options.verbose == 0
...just as you might expect.)
Even niftier, users can run one of
<yourscript> -h
<yourscript> --help
and Optik will print out a brief summary of your script's optons:
usage: <yourscript> [options]
options:
-h, --help show this help message and exit
-fFILE, --file=FILE write report to FILE
-q, --quiet don't print status messages to stdout
That's just a taste of the flexibility Optik gives you in parsing your
command-line. See the documentation included in the package for
details.
AUTHOR, COPYRIGHT, AVAILABILITY
-------------------------------
Optik was written by Greg Ward <gward@python.net>
The latest version of Optik can be found at
http://optik.sourceforge.net/
Copyright (c) 2001 Gregory P. Ward. All rights reserved.
CHANGES IN OPTIK 1.3
--------------------
* Fixed a couple of lurking bugs found by PyChecker.
* You can now get away with not supplying an option's type,
no matter the action: Optik now assumes a default type of "string".
* You can now get away with not supplying an option's destination:
Optik now derives a default destination from the first long option,
or the first short option if no long options were given. Eg. an
option string "--foo-bar" has the default destination 'foo_bar'.
* Refactored both Option's and OptionParser's constructors to
make life easier for people extending Optik.
* Added the "examples/" subdirectory -- this is a repository of
examples of extending and using Optik; the goal is to provide
canonical implementations of various features that I don't want to
add to Optik proper, but that are occasionally requested. (Also,
this gives me a good place to test how Optik's extensibility.)
* Added support for long and complex option types, mainly for
completeness (patch by Matthew Mueller).
* Added make_option() as an alias for the Option constructor, because
someday there might be many Option classes (in which case
make_option() will become a factory function).
--
Greg Ward - geek-at-large gward@python.net
http://starship.python.net/~gward/
Clarke's Law, redux:
Any sufficiently advanced technology is indistiguishable from a rigged demo.