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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 60EA1BB83 for ; Tue, 23 May 2006 19:49:00 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4NHmx6W026191 for ; Tue, 23 May 2006 19:49:00 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA09082 for ; Tue, 23 May 2006 19:48:59 +0200 (MET DST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4NHmw64030233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 23 May 2006 19:48:59 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178031159.adsl.alicedsl.de [85.178.31.159]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id k4NHmqDb024481 for ; Tue, 23 May 2006 19:48:53 +0200 Received: by first.in-berlin.de (Postfix, from userid 501) id 55B04291EDB; Tue, 23 May 2006 19:49:02 +0200 (CEST) Date: Tue, 23 May 2006 19:49:01 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] Use Arg module to read keyword followed by unspecified number of arguments Message-ID: <20060523174901.GB603@first.in-berlin.de> References: <54f15b6e0605231017o5f23fd07q7f7b1c5cab38cf0b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54f15b6e0605231017o5f23fd07q7f7b1c5cab38cf0b@mail.gmail.com> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at nez-perce with ID 44734B0C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44734B0A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 unspecified:01 anonyme:01 specifies:01 endline:01 inverted:01 dirs:01 dirs:01 printf:01 printf:01 hashtbl:01 23,:98 2006:98 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Tue, May 23, 2006 at 12:17:18PM -0500, mulhern wrote: > Hi! > > I expect to be reading something like this: > > -pred-files ... -key2 -extra-files > ... -key4 > > There may be 0 or more specified after -pred-files and after > -extra-files. I need to treat the args differently depending on what > keyword they are associated with. Do you need a keyword for these pred-files arg's? Why don't you use un-named (anonyme) args? It looks like a filelist. The last anonymous function ( "(fun name -> if Sy.file_exists name"(...) ) will be called for all args that are givewn, without a switch that specifies which kind of arg will follow. Example: let parse () = (*print_endline "OK, starting the parse!";*) Arg.parse [ ("-dp", Arg.String (fun x -> dirnameopt := Prefix x), " directory name-prefix"); ("-fd", Arg.String (fun x -> dirnameopt := Fixed x), " fixed directory name"); ("-inv", Arg.Unit (fun () -> filter_selection := Inverted ), " invert the template filter ...