caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Eric Breck <ebreck@cs.cornell.edu>
To: caml-list@inria.fr
Subject: Announcement: syntax extension for parsing command-line options
Date: Wed, 19 Jul 2006 10:47:10 -0400	[thread overview]
Message-ID: <34EE19A7-FAA7-4D21-8AC8-C5644F82097F@cs.cornell.edu> (raw)

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.


                 reply	other threads:[~2006-07-19 14:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34EE19A7-FAA7-4D21-8AC8-C5644F82097F@cs.cornell.edu \
    --to=ebreck@cs.cornell.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).