* Announcement: syntax extension for parsing command-line options
@ 2006-07-19 14:47 Eric Breck
0 siblings, 0 replies; only message in thread
From: Eric Breck @ 2006-07-19 14:47 UTC (permalink / raw)
To: caml-list
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-07-19 14:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-19 14:47 Announcement: syntax extension for parsing command-line options Eric Breck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox