[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]

Arc de Triomphe clipart (2486 bytes)

Optimus - Command Line Argument Parsing in Eiffel

Written by Gregory Patrick Reagle.

Version 0.1.0

optimus-0.1.0.tar.gz (14,000 bytes) - source code
greagl1@umbc.pas-de-spam.edu Gregory Patrick Reagle (maintainer) mail address.


Optimus is a library written in Eiffel that does GNU style command line argument parsing. Optimus is based on the functions getopt() and getopt_long() and should parse the command line just like these functions do. It consists of two classes: COMMAND_LINE_OPTION, and COMMAND_LINE_PARSER.

Compatibility with getopt()

I have written Optimus to be compatible with getopt() and getopt_long() of the GNU C Library based on their GNU info documentation. I have not, however, looked at the source for these two functions at all. The interface to Optimus does not resemble the interface to getopt(); it is of my own design, and object oriented.


The command line consists of a command followed by zero or more command line arguments. There are three types of command line arguments:

  1. arguments to the command, called "command arguments"
  2. options to the command, called "command line options"
  3. argument to the options, called "option arguments"

Command line options can have two forms: short and long. A short option consists of one letter. Short options are preceded by a single hyphen. A long option consists of one or more letters or dashes and is preceded by two hyphens. Here is an example using a hypothetical command:

gtar foo.txt -a -bcd --uncompress --file=foo.gtar -f bar.txt

command argument
short option
three clustered short options
long option
long option with option argument
short option
option argument to -f

Eiffel Compiler Compatibility

Optimus was programmed with SmallEiffel version -0.78. I have not tried it with other compilers. If you want to, try to make it compile with other compilers, and tell me about it. I would be very pleased if someone with a compiler besides SmallEiffel could help. It should not be difficult, and all the ELKS 1995 issues (only 2 of them) are minor and explicitly documented. You are welcome to email with questions.

How To Use

I have tried to make Optimus easy to use. The quickest and easiest way to learn how to use it is to look at the sample client code that I have provided. You can also look at the interfaces (short forms) in plain text and HTML formats.



Contacting the Author

I encourage you to contact me by email (greagl1@umbc.pas-de-spam.edu) with comments, suggestions, criticisms, and compliments or insults. I apologize for the inconvenience, but you must remove ".pas-de-spam" (French for "no spam") from my email addresss. I also encourage you to try to break or find flaws with this software. If you use this library in a program please let me know.

Copyright and License

Optimus is Copyright (c) © 1999 by Gregory Patrick Reagle

Optimus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See the file COPYING for the full license.

Gregory Patrick Reagle: greagl1@umbc.pas-de-spam.edu
Gregory Patrick Reagle's Homepage Page: http://www.gl.umbc.edu/~greagl1/
Optimus Page: http://www.gl.umbc.edu/~greagl1/optimus/optimus.html
04 January 2000 (Added to Eiffel Forum Archive: 19 January 2000)

[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]