Google Groups Home
Help | Sign in
Announcement: syntax extension for parsing command-line options
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Eric Breck  
View profile
 More options Jul 19 2006, 10:49 am
Newsgroups: fa.caml
From: Eric Breck <ebr...@cs.cornell.edu>
Date: Wed, 19 Jul 2006 14:49:11 UTC
Local: Wed, Jul 19 2006 10:49 am
Subject: [Caml-list] Announcement: syntax extension for parsing command-line options
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google