Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] Announcement: syntax extension for parsing command-line options

1 view
Skip to first unread message

Eric Breck

unread,
Jul 19, 2006, 10:49:11 AM7/19/06
to caml...@inria.fr
Hi folks,

Apropos of the recent discussion on the best way to handle command-
line arguments, I'd like to announce the release of pa_arg version
0.2.0, a syntax extension and library for parsing command-line
options. It offers:

* a clean, simple syntax for declaring and using options
* a pure functional interface
* GNU-style or Caml-style handling of options (-ane 'arg' vs -a -n -e
'arg')
* symbol-typed options via polymorphic variants
* generated code to produce a string representation of the chosen
options
* sensible defaults, but powerful, extensible behavior
* and more...

The extension and supporting module, along with a detailed example and
more documentation are available at http://www.cs.cornell.edu/~ebreck/
pa_arg/
It's also available from GODI as godi-pa_arg (or will be as soon as
the GODI svn archive is back up).

I'd like to thank Martin Jambon for his excellent camlp4 tutorial as
well as detailed feedback on previous versions of this extension.

thanks!

Eric Breck

A short example (a longer example is available on the website):

main.ml contains:

open Parseopt
type option opts = {
alpha : help = "smoothing parameter"; float;
beta = false : action = set; bool;
gamma : key = ["-x"]; [`Ecks | `Why | `Zee];
delta : int;
}

if the user types: ./main -alpha 0.45 -b -x why anonymous args

then then the call

parse_argv opts

returns

{alpha=Some 0.45; beta=true; gamma=Some `Ecks; delta=None},
["anonymous";"args"]

PS: If anyone remembers a prior posting of this to ocaml_beginners
last year, this version is considerably improved, but somewhat
different (for one thing,it no longer interfaces to Arg, but provides
its own library). Therefore, it's incompatible with that version.

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

0 new messages