There are some decent command line parsing APIs out there one could copy,
like:

http://visionmedia.github.com/commander.js/
http://code.google.com/p/joptparse/
http://docs.python.org/library/argparse.html#module-argparse

Inevitably, the feature set of all option parsing libraries converge ...
might as well start with a good design.

Cheers,

Dobes



On Mon, Sep 10, 2012 at 5:31 PM, john skaller <skal...@users.sourceforge.net
> wrote:

> 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
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Felix Language" group.
> To post to this group, send email to felix-langu...@googlegroups.com.
> To unsubscribe from this group, send email to
> felix-language+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/felix-language?hl=en.
>
>
------------------------------------------------------------------------------
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