OS Manuals

/usr/bin/gengetopt

A tool to write command line option parsing code for C programs

From gengetopt 2.23.1-r2 (os), captured 2026-11-05 by running gengetopt --help (exit 0). permalink

Usage: gengetopt [OPTION]...
This program generates a C function that uses getopt_long function
to parse the command line options, validate them and fill a struct.

Main options:

  -i, --input=filename          input file (default std input)
  -f, --func-name=name          name of generated function
                                  (default=`cmdline_parser')
  -a, --arg-struct-name=name    name of generated args info struct
                                  (default=`gengetopt_args_info')
  -F, --file-name=name          name of generated file  (default=`cmdline')
      --output-dir=path         output directory
      --header-output-dir=path  header output directory
      --src-output-dir=path     source output directory
  -c, --c-extension=ext         extension of c file  (default=`c')
  -H, --header-extension=ext    extension of header file  (default=`h')
  -l, --long-help               long usage line in help
      --default-optional        by default, an option is considered optional if
                                  not specified otherwise
  -u, --unnamed-opts[=STRING]   accept options without names (e.g., file names)
                                  (default=`FILE')
  -h, --help                    display help and exit
      --full-help               display help, including hidden options, and
                                  exit
      --detailed-help           display help, including all details and hidden
                                  options, and exit
  -V, --version                 output version and exit

The parser generated is thought to be used to parse the command line arguments.
However, you can also generate parsers for configuration files, or strings that
contain the arguments to parse, by using the following two options.

  -C, --conf-parser             generate a config file parser
  -S, --string-parser           generate a string parser (the string contains
                                  the command line)

Additional options:
  -G, --include-getopt          adds the code for getopt_long in the generated
                                  C file
  -n, --no-handle-help          do not handle --help|-h automatically
      --no-help                 do not add --help|-h automatically
  -N, --no-handle-version       do not handle --version|-V automatically
      --no-version              do not add --version|-V automatically
  -e, --no-handle-error         do not exit on errors
      --show-required[=STRING]  in the output of help will specify which
                                  options are mandatory, by using the optional
                                  passed string  (default=`(mandatory)')
      --strict-hidden           completely hide hidden options
  -g, --gen-version             put gengetopt version in the generated file
                                  (default=on)
      --set-package=STRING      set the package name (override package defined
                                  in the .ggo file)
      --set-version=STRING      set the version number (override version
                                  defined in the .ggo file)
      --show-help               show the output of --help instead of generating
                                  code
      --show-full-help          show the output of --full-help (i.e., including
                                  hidden options) instead of generating code
      --show-detailed-help      show the output of --detailed-help (i.e.,
                                  including details and hidden options) instead
                                  of generating code
      --show-version            show the output of --version instead of
                                  generating code

Please refer to the info manual for further explanations.

Maintained by Tomas Volf <wolf@wolfsden.cz>
Report bugs to <bug-gengetopt@gnu.org>
Options (33)
OptionDescriptionSource
-i, --input filenameinput file (default std input)help + man
-f, --func-name namename of generated function (default=`cmdline_parser')help + man
-a, --arg-struct-name namename of generated args info struct (default=`gengetopt_args_info')help + man
-F, --file-name namename of generated file (default=`cmdline')help + man
--output-dir pathoutput directoryhelp + man
--header-output-dir pathheader output directoryhelp + man
--src-output-dir pathsource output directoryhelp + man
-c, --c-extension extextension of c file (default=`c')help + man
-H, --header-extension extextension of header file (default=`h')help + man
-l, --long-helplong usage line in helphelp + man
--default-optionalby default, an option is considered optional if not specified otherwisehelp + man
-u, --unnamed-opts STRINGaccept options without names (e.g., file names) (default=`FILE')help
-h, --helpdisplay help and exithelp + man
--full-helpdisplay help, including hidden options, and exithelp + man
--detailed-helpdisplay help, including all details and hidden options, and exithelp + man
-V, --versionoutput version and exithelp + man
-C, --conf-parsergenerate a config file parserhelp + man
-S, --string-parsergenerate a string parser (the string contains the command line)help + man
-G, --include-getoptadds the code for getopt_long in the generated C filehelp + man
-n, --no-handle-helpdo not handle --help|-h automaticallyhelp + man
--no-helpdo not add --help|-h automaticallyhelp + man
-N, --no-handle-versiondo not handle --version|-V automaticallyhelp + man
--no-versiondo not add --version|-V automaticallyhelp + man
-e, --no-handle-errordo not exit on errorshelp + man
--show-required STRINGin the output of help will specify which options are mandatory, by using the optional passed string (default=`(mandatory)')help
--strict-hiddencompletely hide hidden optionshelp + man
-g, --gen-versionput gengetopt version in the generated file (default=on)help + man
--set-package STRINGset the package name (override package defined in the .ggo file)help + man
--set-version STRINGset the version number (override version defined in the .ggo file)help + man
--show-helpshow the output of --help instead of generating codehelp + man
--show-full-helpshow the output of --full-help (i.e., including hidden options) instead of generating codehelp + man
--show-detailed-helpshow the output of --detailed-help (i.e., including details and hidden options) instead of generating codehelp + man
--show-versionshow the output of --version instead of generating codehelp + man

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.