Path: utzoo!mnetor!uunet!husc6!psuvax1!gondor.cs.psu.edu!schwartz
From: schwartz@gondor.cs.psu.edu (Scott E. Schwartz)
Newsgroups: comp.unix.wizards
Subject: Re: Command interfaces
Message-ID: <3180@psuvax1.psu.edu>
Date: 15 Dec 87 22:22:28 GMT
References: <432@cresswell.quintus.UUCP> <57900005@ccvaxa> <22179@ucbvax.BERKELEY.EDU>
Sender: netnews@psuvax1.psu.edu
Reply-To: schwartz@gondor.cs.psu.edu (Scott E. Schwartz)
Organization: Penn State University, University Park, PA
Lines: 45
Summary: alternative schema

In article <22179@ucbvax.BERKELEY.EDU> Keith Bostic writes:
>In article <57900005@ccvaxa>, aglew@ccvaxa.UUCP writes:
   [quotee unidentified]
>> Another reason not to use getopt: because it requires information to
>> be put in two places. You have to have a string containing your option
>> letters, and a case for the actual option. Bad design.
>
>I am totally lost.  You want to explain how you're going to avoid having
>"information in two places"?
>

Time for a plug for Pr1mos (for a change :-).   Primos has a command
parser called cl$pix.  You give it a picture of the command line in a 
string like   '-f TREE -g TREE -h INT -i -j REST'
and a pointer to a structure that corresponds to those objects:
	01 args
		02 farg string(255)
		02 garg string(255)
		02 harg bin(15)
		02 iarg bit(1) aligned
 		02 jarg bit(1) aligned
		02 rest string(1024) 
(pl/1, anyone?)

Anyway, the information is indeed in some sense in two places, but
the name for each option is in only one place: in the command picture string.	
cl$pix does a great job too.  arguments need not come in any particular
order for it to figure out where they go, you can give alternative names
for switches, and it does some type checking on what you do give it
e.g. -h cat provokes a message to the effect that it was expecting an integer.

If someone with access to Primos docs wants to write a unix version
it would be a good way to see if people prefer that style of option
parsing. (The only Prime I've ever seen is 100s of miles away right now.)

Also, there is a command parser used in one of the columns in Dr.Dobbs
journal that seems to be in this spirit.  It might be worth looking at.

>Why wouldn't you use it?  It's easier to write a command interface with it
>than without it, if you do the interface correctly.  

Certainly getopt is in general better than nothing.


-- Scott Schwartz            schwartz@gondor.cs.psu.edu