GENGETOPT(1)
β¨ NAME β¨
OMG bestie, you found it β this is the manual page for gengetopt, version 2.23.1, and it's literally the User Commands manual. I'm obsessed. π
πΈ SYNOPSIS πΈ
gengetopt [OPTION]...
π DESCRIPTION π
Okay so listen: this program generates a C function that uses the getopt_long function to parse the command line options, validate them, and fill a struct. It's giving code generator realness, and it's lowkey iconic. π₯
π Main options π
-i,--input=filenameβ input file (default std input). So if you don't give it a file, it reads from standard input, no cap.-f,--func-name=nameβ name of generated function (default=cmdline_parser). You can rename it, slay.-a,--arg-struct-name=nameβ name of generated args info struct (default=gengetopt_args_info). The struct gets a name too, cute.-F,--file-name=nameβ name of generated file (default=cmdline). Like, the base filename without extension.--output-dir=pathβ output directory. If this option is not specified, the files are generated in the current directory. So if you're lazy like me, it's fine. π--header-output-dir=pathβ header output directory. Separate place for the header, fancy.--src-output-dir=pathβ source output directory. And the source can go somewhere else too.-c,--c-extension=extβ extension of c file (default=c). It's justc, no dot, iykyk.-H,--header-extension=extβ extension of header file (default=h). Same vibe.-l,--long-helpβ long usage line in help. The usage line will print all the options, e.g.,sample1 -iINT|--int-opt=INT [-h|--help]. Obsessed with the detail.--default-optionalβ by default, an option is considered optional if not specified otherwise. So if you don't say, it's optional. Periodt.-u,--unnamed-opts[=STRING]β accept options without names (e.g., file names) (default=FILE). Like, positional args basically. The default placeholder isFILE.--unamed-opts[=STRING]β synonym for--unnamed-opts, accepted for backwards compatibility (default=FILE). Note the typo: it's missing an 'n' in "unamed" β that's on purpose for backwards compat, don't @ me. π-h,--helpβ display help and exit. The classic.--full-helpβ display help, including hidden options, and exit. Spill the hidden tea.--detailed-helpβ display help, including all details and hidden options, and exit. All the details, no secrets.-V,--versionβ output version and exit. Slay.
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. For when you wanna parse a config file instead of the command line. π-S,--string-parserβ generate a string parser (the string contains the command line). So you can pass a string that looks like the command line. Iconic.
π Additional options π
-G,--include-getoptβ adds the code forgetopt_longin the generated C file. So it's self-contained, no external getopt needed.-n,--no-handle-helpβ do not handle--help|-hautomatically. If--no-handle-helpis specified, the command line option--help|-hwill 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|-hmanually, 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. So basically, the parser bails after seeing help. Important. π¨--no-helpβ do not add--help|-hautomatically. 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 characterhas he wants, but he cannot define optionshelp, unless he specifies--no-help(otherwise an error will be printed). So like, you can have-hbut not--helpunless you use this flag. Big brain. π§-N,--no-handle-versionβ do not handle--version|-Vautomatically. Same vibe as--no-handle-helpbut for version.--no-versionβ do not add--version|-Vautomatically. See above the details about--no-handle-helpand--no-help, respectively. So it's the same pattern.-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. So you get to handle errors yourself, main character energy.--show-required[=STRING]β in the output of help will specify which options are mandatory, by using the optional passed string (default=(mandatory)). So you can customize the mandatory label. Cute.--strict-hiddenβ completely hide hidden options. Like, no trace. π-g,--gen-versionβ put gengetopt version in the generated file (default=on). It's on by default, so the generated file tells you what version made it. Meta.--set-package=STRINGβ set the package name (override package defined in the.ggofile). So you can override what's in the input file.--set-version=STRINGβ set the version number (override version defined in the.ggofile). Same but for version.--show-helpβ show the output of--helpinstead of generating code. Like a preview, but for the help text.--show-full-helpβ show the output of--full-help(i.e., including hidden options) instead of generating code. Preview with hidden tea.--show-detailed-helpβ show the output of--detailed-help(i.e., including details and hidden options) instead of generating code. Preview with all the details.--show-versionβ show the output of--versioninstead of generating code. Preview the version.
Please refer to the info manual for further explanations. Maintained by Tomas Volf <wolf@wolfsden.cz>. Shoutout to Tomas, keeping it real. π
π¨ REPORTING BUGS π¨
Report bugs to <bug-gengetopt@gnu.org>. Be nice, bestie, they're doing their best. π
π COPYRIGHT π
Copyright Β© 1999-2011 Free Software Foundation Inc. This program comes with ABSOLUTELY NO WARRANTY; for details please see the file 'COPYING' supplied with the source code. This is free software, and you are welcome to redistribute it under certain conditions; again, see 'COPYING' for details. This program is released under the GNU General Public License. So like, no warranty, free software, GNU GPL, read the COPYING file for the legal tea. βοΈ
π SEE ALSO π
The full documentation for gengetopt is maintained as a Texinfo manual. If the info and gengetopt programs are properly installed at your site, the command
info gengetopt
should give you access to the complete manual. So go read that if you want the whole story. π
That's it, bestie! This page was brought to you by GNU gengetopt 2.23.1, dated September 2026 π β¨. Now go generate some slay command line parsers. π¦
π¦ where this page comes from
- arch rolling: gengetopt 2.23.1-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms