GENGETOPT(1)

NAME
gengetopt - generate a C function which parses command line arguments

SYNOPSIS
gengetopt [OPTIONS...] [< file]

DESCRIPTION
gengetopt reads a description file for command line arguments and generates a C function which uses the GNU getopt_long(3) library function to parse the command line arguments.

gengetopt supports: long and short options (per the GNU Coding Standards), 10 types of parameters (including flag, int, double, string, and function call), and a usage message.

gengetopt itself is under the GPL. The code it generates is not under any license. See LICENSE.

THIS MAN PAGE IS NOT COMPLETE.

Texinfo documentation will be released soon, but meanwhile please refer to README file or to the html documentation that you can find in /usr/local/share/doc/gengetopt.

OPTIONS
gengetopt accepts some options.

   -h         --help                Print help and exit
   -V         --version             Print version and exit
   -iSTRING   --input=STRING        input file (default std input)
   -fSTRING   --func-name=STRING    name of generated function (default='cmdline_parser')
   -FSTRING   --file-name=STRING    name of generated file (default='cmdline')
   -l         --long-help           long usage line in help
   -u         --unamed-opts         accept filenames
              --no-handle-help      do not handle --help|-h automatically
              --no-handle-version   do not handle --version|-V automatically
              --no-handle-error     do not exit on errors

INPUT
The description file consists of lines with the following format:

     package packname
     version version
     purpose purpose
     option long short desc argtype (default="default val") required
     option long short desc flag    onoff
     option long short desc no
     ... # ...

`#' anywhere in a line starts a comment which continues to the end of the line. The data items are as follows:

packname
    Double quoted string.

version
    Double quoted string.

purpose
    Double quoted string with also newlines.

long
    The long option, a double quoted string with upper and lower case chars, digits, `-' and `.'. No spaces allowed. The name of the variables generated to store arguments are long options converted to be legal C variable names. This means, `.' and `-' are both replaced by `_'. `_arg' is appended, or `_flag' for a flag.

short
    The short option, a single upper or lower case char, or a digit. If a '-' is specified, then no short option is considered for the long option (thus long options with no associated short options are allowed).

desc
    Double quoted string.

argtype
    string, int, short, long, float, double, longdouble or longlong.

default
    (Optional) Double quoted string. Specify the default value for this option.

required
    yes or no.

onoff
    on or off. This is the state of the flag when the program starts. If user specifies the option, the flag toggles.

The third type of option is used to call an arbitrary function. It must not be required. (Otherwise, why is it an option if it doesn't take a parameter?)

Options --help and --version are generated automatically.

EXAMPLE
Here's an example of a description file:

  # file sample1.ggo
  option  "str-opt"         s "A string option"      string     no
  option  "my-opt"          m "Another integer option"      int     no
  option  "int-opt"         i "A int option"         int        yes
  option  "flag-opt"        - "A flag option"        flag       off
  option  "funct-opt"       F "A function option"    no
  option  "long-opt"        - "A long option"        long       no
  option  "def-opt"         - "A string option with default" string default="Hello" no

SEE ALSO
HTML documentation in /usr/local/share/doc/gengetopt.
Examples in /usr/local/share/doc/gengetopt/examples.

VERSION INFORMATION
This man page (partially) documents gengetopt, version 2.7.1. TexInfo documentation will be released soon.

AUTHOR
This man page was written by James R. Van Zandt <jrv@vanzandt.mv.com>, for the Debian GNU/Linux system (but may be used by others). It was modified by Lorenzo Bettini <bettini@gnu.org> the current maintainer of GNU gengetopt.