Browse thread
Use Arg module to read keyword followed by unspecified number of arguments
-
mulhern
- Till Varoquaux
- Oliver Bandel
- Oliver Bandel
- Michael Wohlwend
- Richard Jones
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Michael Wohlwend <micha-1@f...> |
| Subject: | Re: [Caml-list] Use Arg module to read keyword followed by unspecified number of arguments |
On Tuesday 23 May 2006 19:17, mulhern wrote: > Hi! > > I expect to be reading something like this: > > -pred-files <arg1> <arg2> ... <argn> -key2 <arg> -extra-files <arg1> > <arg2> ... <argn> -key4 I think the idea by Till to separate the args with commas is best, but if you don't want to do this, maybe something like that would be o.k. : let mode_pred = ref true;; let pred_files = ref [];; let extra_files = ref [];; let key2 = ref "";; Arg.parse [ "-extra-files", Arg.Clear mode_pred, "extra files"; "-key2", Arg.Set_string key2, "key2"; "-pred-files", Arg.Set mode_pred, "pred files" ] (fun name -> if !mode_pred then pred_files := name :: !pred_files else extra_files := name :: !extra_files ) "usage..." ;; cheers, Michael -- C offers you enough rope to hang yourself. C++ offers a fully equipped firing squad, a last cigarette and a blindfold.