clig — Command Line Interpreter Generator
For the impatient and those who know
You can download the gzipped PostScript documentation, or the latest release as clig-1.9.11.2.tar.xz.
If you know clig
already, you may be interested in the
changes since the last release.
You can also download older versions of clig.
Remark: clig is not CLIG. If you were looking for the Clig Grapher for linguistic data structures by Karsten Konrad, you should go to the CLIG homepage . Both tools are un-related to one another. They share their names only due to a historical coincidence.
What is clig?
Clig creates for your C-Program or lets you use it in your Tcl-script.
- A command line interpreter with the following features:
- Flag, Int, Long, Float, Double or String options
- number of parameters of options can be specified
- a range can be specified for the numerical options
- options can have defaults
- options can be mandatory (not really optional then) :-)
Parsed results are delivered to your C-program in a custum-built structure or as directly accessible variables to your Tcl-script. - a readable, up-to-date usage-message
- a basic manual page
Clig takes as input a simple description file.
Clig generates standard C (well, I tried as hard as I can) :-) It is reported to work well with C++. Within a Tcl-script, code generation is not necessary. Just declare your command line arguments and then run the parser.
The resulting code is self contained and does not depend on a library (except for libc, of course).
Clig is written in Tcl
Clig is free software. Its licence is the GPL.
An Example
Consider the following specification:
It shows most of the features available in clig
. Here an option
-rgb
is declared with parameters of type int
. Within the
C-program or Tcl-script, it will be called rgb
. The next line contains
in quotes a usage string to be displayed by the generated
usage()
-function. The line -c 3 3
specifies that the
option -rgb
must be followed by at least 3 but no more than three (i.e.
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.
-
Double
- is an option with zero or more
double
parameters. -
Int
- accepts zero or more int parameters.
-
Long
- accepts zero or more long (i.e. 8 byte int on some machines) 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 WINDOWS program group,
- Ole, Nils or Jens support,
- InactiveX-aware buzzword-recognition.
Requirements
Clig
is implemented in Tcl, and it will not work without it. The
generated C-code is Tcl-free.
Installation
Clig is currently developed on FreeBSD
Install using the FreeBSD
ports system:
cd /usr/ports/devel make install cleanInstall using the FreeBSD pkg system:
pkg install devel/clig
Clig was originally written, and developed by Harald Kirsch, and is now mantained by Chris Hutchinson.
Please send comments and suggestions to portmaster (Chris). Flames expressing the opinion that
getopt()
is the only way to go are
silently ignored.