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 just c, 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 is FILE.
  • --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 for getopt_long in the generated C file. So it's self-contained, no external getopt needed.
  • -n, --no-handle-help β€” do not handle --help|-h automatically. If --no-handle-help is 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. So basically, the parser bails after seeing help. Important. 🚨
  • --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-help will also disable the automatic options --detailed-help and --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). So like, you can have -h but not --help unless you use this flag. Big brain. 🧠
  • -N, --no-handle-version β€” do not handle --version|-V automatically. Same vibe as --no-handle-help but for version.
  • --no-version β€” do not add --version|-V automatically. See above the details about --no-handle-help and --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 .ggo file). So you can override what's in the input file.
  • --set-version=STRING β€” set the version number (override version defined in the .ggo file). Same but for version.
  • --show-help β€” show the output of --help instead 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 --version instead 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 Β© 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