Gretl — An application framework for OCaml
Gretl is an application framework for OCaml, it implements components and services which can be used to develop OCaml applications. It offers:
- Processing of command line arguments
- A simple and powerful internationalisation-friendly diagnostic facility
- Analyse of configuration files
- A cascading system for configuration values, usable to implement site policies
- Unicode support
- Stock application patterns, like a Unix filter or a compiler
We call a program using the Gretl framework a Gretl guest.
Within an application, exposed values are values which are immediately exposed to the user by the application. In a typical Unix application, exposed values are booleans, numbers and strings. A personal accounting software would add currencies to the mix, while scientific software is likely to introduce types specific to the problem its solves.
A Gretl guest must define a
Values module implementing its own idea
of exposed values. Gretl implements the following exposed values
modules which can be used by its guests:
- CValue, suited for standard Unix applications
- UValue, suited for Unicode capable applications
Exposed values must support a formatting facility similar to
The diagnostic facility of Gretl is built upon exposed values. It allows a fine control of the verbosity and the routing of diagnostic messages of an application.
Messages are emitted to a sink and annotated with a severity level, much like the classical Unix syslog facility does. Messages can be translated using a translation database.
One attaches output channels to a sink, which are actually responsible for sending bytes to a device, should it be a classical Unix output channel, an attached process, an Email program, or anything similar.
A scribe module is used by sinks to send exposed values to output channels.
An application can examine configuration values provided by the application user or the system administrator. These values are exposed values.
Configuration values can be added from several sources:
- Configuration files
- Command line
- Gnome configuration dæmon
The application designer can define a cascading scheme for the sources, which can eventually used by the system administrator to enforce some configuration values.
The facility built in Gretl is a configuration-time facility but a MVC-style facility could be interesting for dæmons.
Command line arguments
We support reading command line arguments in the traditional Unix way, with clustered arguments and also long options. Command line parameters can supply configuration values but they can also trigger more complex behaviors, as it is usaully the case for Unix programs.
Deviant analyse patterns, such as used by
tar are not
We implement several application patterns, which are the high level blocks used by Gretl clients: a Gretl client only needs to interact with the module implementing the selected application pattern (and its submodules).
We implement the following application patterns:
- Plain Unix application
- Unix filter
- Unix compiler
- Unicode filter
- Unicode compiler
We implement a unit test framework supporting test automation, sharing of setup and teardown code between tests and aggregation of tests in collections.
With this framework, it is easy to create a
which can run all or a subset of available test suites and reports the
outcome of the tests with its exit status.
Symbolic exit codes
We support symbolic exit codes as described by sysexits(3) on FreeBSD systems.