From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBRHYMFW016395 for ; Mon, 27 Dec 2010 18:34:22 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4BANdcGE3ZSMDqi2dsb2JhbACWFI4bFQEBAQoLCgcPBSG+dYVKBI4h X-IronPort-AV: E=Sophos;i="4.60,235,1291590000"; d="scan'208";a="84761716" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail2-smtp-roc.national.inria.fr with ESMTP; 27 Dec 2010 18:34:16 +0100 Received: from smtp03.web.de ( [172.20.0.65]) by fmmailgate03.web.de (Postfix) with ESMTP id BE4671830B7F5 for ; Mon, 27 Dec 2010 18:32:34 +0100 (CET) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp03.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PXGvy-0001s6-00 for caml-list@yquem.inria.fr; Mon, 27 Dec 2010 18:32:34 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1PXGvy-0000CG-5v for caml-list@yquem.inria.fr; Mon, 27 Dec 2010 18:32:34 +0100 From: Goswin von Brederlow To: caml-list@yquem.inria.fr Date: Mon, 27 Dec 2010 18:32:34 +0100 Message-ID: <874o9zw28d.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX19vr47CJw370YKXnHJWX9U3dThR9yKm/kNITqO7 wAlGUBKKn9S6vBzDQN/yu4ed7tnIqpsKjy3Gs+h1DmWsKTY1+B 7/vQmBAls= Subject: [Caml-list] Command line argument parsing Hi, I'm looking for a better (as more suitable to my wishes :) module to do command line argument parsing. So far I've looked at Arg and Getopt. Args has a nice automatic help text while Getopt supports short and long options. I want both. :) Further both only allow parsing all option in one go. So what am I looking for? ========================= Consider the following usage: foo [-p|--port ] [-h|--help] [-v|--verbose] [[-f|--file] ] [...] port defaults to 1234 Then I want to write something like: let port_arg = Int [Short 'p'; Long "port"; Once; Default 1234] let help_arg = Unit [Short 'h'; Long "help"; Exit; ] let verbose_arg Count [Short 'v'; Long "verbose" ] let file_arg = Call_String ([Short 'f'; Long "file" ], (fun s -> process s)) let port = extract port_arg let verbose = extract verbose_arg let () = extract help_arg let () = parse [file_arg] (fun s -> process s) "Help text header" I don't want to have to use a ref or mutable to define a port and then overwrite it when parsing the arguments. Anyone know something in that direction? MfG Goswin