From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 1020FBB83 for ; Wed, 19 Jul 2006 16:46:18 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6JEkHLa027036 for ; Wed, 19 Jul 2006 16:46:17 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA14637 for ; Wed, 19 Jul 2006 16:46:17 +0200 (MET DST) Received: from exchfe2.cs.cornell.edu (exchfenlb-2.cs.cornell.edu [128.84.97.34]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6JEkGmU030260 for ; Wed, 19 Jul 2006 16:46:16 +0200 Received: from exchfe2.cs.cornell.edu ([128.84.97.28]) by exchfe2.cs.cornell.edu with Microsoft SMTPSVC(6.0.3790.1830); Wed, 19 Jul 2006 10:46:15 -0400 Received: from [192.168.1.100] ([24.59.194.44]) by exchfe2.cs.cornell.edu over TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); Wed, 19 Jul 2006 10:46:15 -0400 Mime-Version: 1.0 (Apple Message framework v752.2) Content-Transfer-Encoding: 7bit Message-Id: <34EE19A7-FAA7-4D21-8AC8-C5644F82097F@cs.cornell.edu> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@inria.fr From: Eric Breck Subject: Announcement: syntax extension for parsing command-line options Date: Wed, 19 Jul 2006 10:47:10 -0400 X-Mailer: Apple Mail (2.752.2) X-OriginalArrivalTime: 19 Jul 2006 14:46:15.0291 (UTC) FILETIME=[160EFCB0:01C6AB42] X-Miltered: at concorde with ID 44BE45B9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44BE45B8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; syntax:01 parsing:01 command-line:01 syntax:01 parsing:01 command-line:01 variants:01 defaults:01 camlp:01 bool:01 argv:01 ocaml:01 beginners:01 0.45:98 0.45:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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.