gengetopt reads an interface description file, and writes a skeleton
main.c file. gengetopt supports: long and short options, 11 types of
parameters (including flag, int, double, string, and function call),
and a usage message.
GNU Gengetopt
This program generates a C function that uses /getopt_long/ function to
parse the command line options, to validate them and fills a /struct/ .
Thus your program can now handle options such as:
myprog --input foo.c -o foo.o --no-tabs -i 100 *.class
And both long options (those that start with --) and short options
(start with - and consist of only one character) can be handled
more»
#!/bin/sh -v
# commands to try the C++ example:
gengetopt -isample1.ggo -Fcmdline1 --long-help -u
c++ -o main1 main1.cc cmdline1.c
./main1 --help
# commands to try the C example:
gengetopt --input=sample2.ggo --func-name=my_cmdline_parser --file-name=cmdline2 --unamed-opts
gcc -o main2 main2.c cmdline2.c
./main2 -h