gengetopt1
Manual page for gengetopt 2.23.1
Usage
gengetopt [OPTION] ...
Overview
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
-
if this option is not specified, the files are generated in the current 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
|
The usage line will print all the options, e.g., |
|
|
sample1 |
-
--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')
-
--unamed-opts[=STRING] -
synonym for
--unnamed-opts, accepted for backwards compatibility (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
-
If
--no-handle-helpis specified, the command line option--help|-h will not be handled automatically, so the programmer will be able to print some other information; then the function for printing the standard help output can be used; this function is called <parser-name>_print_help.
-
Notice that, although the programmer can handle
--help|-h manually, the parser will return after finding such option: the other command line options, if any, will be ignored. In case you want to have full control on--help|-h, you should use--no-help.
-
--no-help -
do not add
--help|-h automatically
-
With this option you can disable the automatic addition of options
--help|-h. The programmer will then be able to add this option in the input file and handle it as he sees fit. Notice that--no-helpwill also disable the automatic options--detailed-helpand--full-help.
-
The programmer can still define options with short character h as he wants, but he cannot define options help, unless he specifies
--no-help(otherwise an error will be printed).
-
-N, --no-handle-version -
do not handle
--version|-V automatically
-
--no-version -
do not add
--version|-V automatically
-
See above the details about
--no-handle-helpand--no-help, respectively.
-
-e, --no-handle-error -
do not exit on errors
-
With this option, if the generated parser encounters an error (e.g., an unknown option) it does not make the main program exit; instead, the parser function returns a value different 0, and the main program can print a help message.
-
--show-required[=STRING] -
in the output of help will specify which options are mandatory, by using the optional passed string (default=`(mandatory)')
-
-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
--helpinstead 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
--versioninstead of generating code
Please refer to the info manual for further explanations.
Maintained by Tomas Volf <[email protected]>
Releases
8 releases since Debian 2.2 (Potato); the text changed 7 times.
--arg-struct-name since Debian 4.0 (Etch);
--c-extension since Debian 4.0 (Etch);
--conf-parser since Debian 4.0 (Etch);
--default-optional since Debian 5.0 (Lenny);
--detailed-help since Debian 5.0 (Lenny);
--file-name since Debian 4.0 (Etch);
--full-help since Arch Linux 2026-11-01;
--func-name since Debian 4.0 (Etch);
--gen-version since Debian 4.0 (Etch);
--header-extension since Debian 4.0 (Etch);
--header-output-dir since Debian 6.0 (Squeeze);
--help since Debian 4.0 (Etch);
--include-getopt since Debian 4.0 (Etch);
--input since Debian 4.0 (Etch);
--long-help since Debian 4.0 (Etch);
--no-handle-error since Debian 4.0 (Etch);
--no-handle-help since Debian 4.0 (Etch);
--no-handle-version since Debian 4.0 (Etch);
--no-help since Debian 5.0 (Lenny);
--no-version since Debian 5.0 (Lenny);
--output-dir since Debian 4.0 (Etch);
--set-package since Debian 4.0 (Etch);
--set-version since Debian 4.0 (Etch);
--show-detailed-help since Debian 5.0 (Lenny);
--show-full-help since Debian 4.0 (Etch);
--show-help since Debian 4.0 (Etch);
--show-required since Debian 5.0 (Lenny);
--show-version since Debian 4.0 (Etch);
--src-output-dir since Debian 6.0 (Squeeze);
--strict-hidden since Arch Linux 2026-11-01;
--string-parser since Debian 4.0 (Etch);
--unamed-opts since Debian 4.0 (Etch);
--unnamed-opts since Arch Linux 2026-11-01;
--version since Debian 4.0 (Etch);
-C since Debian 4.0 (Etch);
-F since Debian 4.0 (Etch);
-G since Debian 4.0 (Etch);
-H since Debian 4.0 (Etch);
-N since Debian 4.0 (Etch);
-S since Debian 4.0 (Etch);
-V since Debian 4.0 (Etch);
-a since Debian 4.0 (Etch);
-c since Debian 4.0 (Etch);
-e since Debian 4.0 (Etch);
-f since Debian 4.0 (Etch);
-g since Debian 4.0 (Etch);
-h since Debian 4.0 (Etch);
-i since Debian 4.0 (Etch);
-l since Debian 4.0 (Etch);
-n since Debian 4.0 (Etch);
-u since Debian 4.0 (Etch).