command line options

Richard Harter g-rh at cca.CCA.COM
Fri Apr 1 19:03:51 AEST 1988


The discussions on options are of particular interest to me because I
expect to be revising an options package in the near future.  (Real soon
now.)  I don't mind a fair bit of work, but I want to get the spec's
right.  Here are some considerations:

(1)	Must be able to handle multiple calls with different argument
vectors.  [This is an internal requirement.]

(2)	Must be able to turn flags on and off.  This is hand in hand with
requirement (1).  This is a problem.  Currently we are using - for off
and + for on.  From a human engineering viewpoint this seems essential.
However this conflicts with unix usage.

(3)	Must be case insensitive if the key values are all the same case.

(4)	Must be able to handle key values with more than one letter.

(5)	Must be able to handle abbreviations to the level of ambiguity.

(6)	Insofar as possible, must be consistent with getopt.  In particular
if all key values are unambiguous at the one letter level, one should be
able to group them.

(7)	Should be able to handle various types and do the appropriate
interpretation.  Should also be able to invoke a processing routine for
an option value.

(8)	Should be able to handle a list of positional arguments which
don't have option keys.  It should be possible to intermix these
with options which do have keys.  [Compatibility considerations.]

(9)	Must be able to return a list of all arguments which are not
key value or postional options, or some equivalent mechanism.

(10)	For sundry internal reasons, must be able to support -key value
and key=value.

(11)	Under consideration is white space elimination and white space
requirement rules.  In particular, if k is a key letter, getopt allows

	-kvalue

We would like to do this, to be consistent with getopt.  Precise rules
for doing this while allowing multiple letter keys are yet to be
determined.  There are also questions about 

	-foo-bar

(12)	Error handlers should be specifiable.

(13)	It would be preferable that the entire options processing package
be self contained.

(14)	Also preferred is that there be no globals involved.

As I say, these are preliminary desiderata.  Any suggestions or comments
would be appreciated.  
-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.



More information about the Comp.lang.c mailing list