English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Use Arg module to read keyword followed by unspecified number of arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-05-23 (17:29)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] Use Arg module to read keyword followed by unspecified number of arguments
You could work around with references but I guess you'd consider this
as ugly. A comma separated list of strings could do the trick:
 "-pred-files", Arg.String (fun s -> predfiles:=Str.split
(Str.regexp_string ",") s),"...")

On 5/23/06, mulhern <mulhern@gmail.com> wrote:
> Hi!
> I expect to be reading something like this:
> -pred-files <arg1> <arg2> ... <argn> -key2 <arg> -extra-files <arg1>
> <arg2> ... <argn> -key4
> There may be 0 or more <args> specified after -pred-files and after
> -extra-files. I need to treat the args differently depending on what
> keyword they are associated with.
> I can think of about 10 ways to do this using the Arg module, but
> they're all ugly and all different. Does anybody have an attractive
> solution to this problem or is aware of the accepted way to handle
> this situation? An example in some existing code would be good enough.
> I do not consider changing the call to
> -pred-files <arg1> -pred-files <arg2> ... -pred-files <argn> ......
> an option at this time, principally because the call is automatically
> generated and I'ld like it to stay in line with the other
> automatically generated calls in the same distribution.
> Thanks!
> -mulhern
> _______________________________________________
> 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