I am sick of hacking up parsers for command line options.
So I propose this:

Given an array of words, we will translate according to a cut down GNU option
syntax.

We make a string->list[string] dictionary:
if the option has the form:

(a) --name=argument

        Put key = --name, value = Cons (argument, oldarguments) into the 
dictionary.

(b) --option

    Put key --option, cons  "" onto value

(c) -abcdef

put each of -a, -b, -c ... into the dictionary cons value ""

(d) other

   Put key = "", value = Cons (argument, oldarguments) into the dictionary


get-option function is given a key and returns a list of options.
It cannot fail. It returns Empty[string] if the option is not set.
It returns list("") if the option is set once but has no value given.

According to these rules all options have the form:

        --key=value

where either --key= or =value can be omitted,
EXCEPT for the sugar -abcd.

To cope with -I includefile, we can pre-process the
input array.


JSON like thing is another thought.
bash at least allows [ ] { } , : without munging
which is enough to put json on command lines.

[flx, {c:true, I:includefile}, cmd, arg, arg]

looks kind of weird though :-)


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to