clig --- Command Line Interpreter Generator
... to all those still using C.
For the impatient and those who know
You can download the gzipped PostScript documentation or the
latest release |CLIGTARGZ|, which
includes the documentation.
If you know clig already, you may be interested in the
changes since the last release.
If you feel the need to download older versions, have a look at the
software-directory.
What is clig?
Clig uses a simple description to generate C-code
for a function
Cmdline *parseCmdline(int argc, char **argv)
which parses the command-line of a typical C-program and
returns the result in a structure of type Cmdline.
However, one of the main reasons to use clig is maybe the automatic
generation of a usage()-function which is always
up-to-date with respect to the options actually understood by the
program.
An Example
Consider the following specification:
Int -rgb rgb \
"specifies a color by its red, green and blue components"\
count=3,3 \
range=0,255
It shows most of the features available in clig. Here an
option -rgb is declared with parameters of type
int. Within the C-program, it will be called
rgb. The next line contains in quotes a usage string to
be displayed by the generated usage()-function. The line
count=3,3 specifies that the option -rgb
must be followed by exactly 3 integer values. Finally the allowed
range for the three values is specified.
An example demonstrating most features of clig is also available.
Currently, clig understands the following option types:
-
Flag
- is a boolean option (or flag) without parameters.
-
Float
- is an option with zero or more floating point parameters.
-
Int
- accepts zero or more integer parameters.
-
String
- allows arbitrary strings as parameters.
For floating point, integer and string valued options a range can be
specified for the number of allowed parameters. The allowed range for
floating point and integer option values can also be specified.
Features missing on my todo-list
- neural net type command line parser,
- fuzzy logic command line parser,
- inheritance hierarchy for command line options,
- visual basic support,
- command lines shorter than 128 characters,
- generation of WINDOS program group,
- Ole, Nils or Jens support,
- InactiveX-aware buzzword-recognition.
Looks like Java is missing on the list? Yes, because Jclig is already
available for almost a year. But since I am not (yet) actively
programming in Java, it is not ready to ship.
Requirements
Clig is implemented in Tcl and you will not be able to
make it work without. The generated C-code is Tcl-free.
Please send comments and suggestions to
Harald Kirsch. Flames expressing
the opinion that getopt() is the only way to go are
silently ignored.