Next: , Previous: , Up: Header declarations   [Contents][Index]

4.9.2 Command-line arguments

coNCePTuaL makes it easy to declare command-line parameters, although the syntax is a bit verbose:

<param_decl> ::= <ident>
IS <string>
AND COMES FROM <string> OR <string>

<ident> is the coNCePTuaL variable being declared. The first <string> is a descriptive string that is provided when the user runs the program with --help or -?. The ‘ <string> OR <string>’ terms list the long name for the command-line option, preceded by ‘--’, and the short (single-character) name, preceded by ‘-’. Finally, <expr> specifies the value that will be assigned to <ident> if the command-line option is not used. <expr> must be a constant expression and may not utilize any of the random-number functions listed in Random-number functions. Note that short names (also long names) must be unique.

For instance, the declaration ‘nummsgs IS "Number of messages to send" AND COMES FROM "--messages" OR "-m" WITH DEFAULT 25*4’ declares a new coNCePTuaL variable called ‘nummsgs’. ‘nummsgs’ is given the value ‘100’ (‘25*4’) by default. However, if the user running the program specifies, for example, --messages=55 (or, equivalently, -m 55), then ‘nummsgs’ will be given the value ‘55’. The following is an example of the output that might be produced if the program is run with --help or -?:

Usage: a.out [OPTION...]
  -m, --messages=<number>     Number of messages to send [default: 100]
  -C, --comment=<string>      Additional commentary to write to the log
                              file, @FILE to import commentary from FILE,
                              or !COMMAND to import commentary from COMMAND
                              (may be specified repeatedly)
  -L, --logfile=<string>      Log-file template [default: "a.out-%p.log"]
  -N, --no-trap=<string>      List of signals that should not be trapped
                              [default: ""]

Help options:
  -?, --help                  Show this help message
  --usage                     Display brief usage message

The above is only an example. Depending on what libraries were available when the coNCePTuaL run-time system was configured, the output could be somewhat different. Also, long options may not be supported if a suitable argument-processing library was not available at configuration time. The above example does indicate one way that help strings could be formatted. It also shows that the coNCePTuaL run-time system reserves some command-line options for its own purposes. Currently, these all use uppercase letters for their short forms so it should be safe for programs to use any lowercase letter.

Next: , Previous: , Up: Header declarations   [Contents][Index]

Scott Pakin,