AutoGen's Automated Option Processing


XML Defs


Man example
local use
using getopt






Project GNU
Home Page


xdr project


AutoOpts 40:1 (online documentation) is included with AutoGen 5.18.1. It is a very powerful command line, configuration file and environment variable option parser (see its feature list and a comparison with other parsers *). Additionally, it will produce man pages and texinfo GNU-style invoking chapters. It consists of a set of AutoGen templates and a run time library. This suite of tools eliminates the repetitive nature of handling and documenting program options, and the consequential propensity for inconsistencies.

Using your program's option definitions, AutoGen will expand the AutoOpts templates into all of these different text files. The header and code files contain all the information the AutoOpts library needs to parse and handle options from the command line, environment variables and configuration files. The section 1 man page is ready to be installed directly. The texinfo chapter (or section) is ready to be included in your full program document. Repetition and consistency issues are solved.

If you wish to use getopt_long(3GNU) or getopt(3C) to parse the options instead of AutoOpts' libopts library, you may do so. A template (getopt.tpl) is distributed with AutoOpts that will take restricted AutoOpts option definitions and produce the parsing loop that calls either getopt or getopt_long, then handles each option by setting state or calling a callback function. (Choosing between getopt or getopt_long depends on whether long options are enabled in your program description.) Be aware, though, that it is necessarily crippled when compared with the full set of AutoOpts Features

AutoOpts option processing is also internationalizable. If you compile with ENABLE_NLS defined and the _() macro defined to a localization function such as gettext(3GNU), then the option processing code will be localizable. Simply run xgettext, or equivalent, on the distributed header, usage-txt.h and add it to the rest of your i18n. When you call optionProcess, all of the user visible AutoOpts strings will be passed through the localization procedure established with the _() preprocessing macro. The AutoOpts library will always check for the compiled with NLS flag, so the libopts library does not need to be specially compiled.

To do all of this, this package is necessarily very complicated. If you are considering getting started, it is likely you are only interested in a tiny fraction of this functionality. Please see the quick start guide and experiment with that. If you have a requirement that is not covered by the example, you can search for what you need, add it in and it will all "just work".

AutoOpts, the full package, is licensed under the "Lesser" (Library) GNU Public License (LGPL). The shared library portion of it, however, is available separately. The libopts tear-off library is available under either of two licenses: the LGPL, or, optionally, the advertising-clause-free BSD license.

If you are interested in trying this package, the full documentation is here online and it is included with the AutoGen distribution. (If you choose to download, or have any other questions, please drop a note and let me know if you built it and what you used it for.
Thanks! :)

*If the comparison page lies or is incomplete, please let know. I don't track other projects all the time. Or even necessarily keep the AutoOpts features up-to-date!

top  Viewable With Any Browser  Valid XHTML 1.0!

AutoGen, AutoOpts, columns, getdefs, AutoFSM, AutoXDR and these web pages copyright (c) 1999-2012 Bruce Korb, all rights reserved.

Return to GNU's home page.

Please send FSF & GNU inquiries & questions to There are also other ways to contact the FSF.

Please send comments on these web pages to, send other questions to

This article, Copyright © 2000-2002 by Bruce Korb

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. Last modified: Sun Sep 8 12:45:35 PDT 2013