Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file conf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128(*
* Copyright (c) 2017 Daniel C. Bünzli
* Copyright (c) 2017 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)type'aparser=string->('a,[`Msgofstring])resulttype'aprinter='aFmt.ttype'aconverter='aparser*'aprinterletparser(p,_)=pletprinter(_,p)=pletstr=Printf.sprintfletquotes=str"`%s'"smoduleErr=structletalts=function|[a;b]->str"either %s or %s"ab|alts->str"one of: %s"(String.concat", "alts)letinvalidkindsexp=str"invalid %s %s, %s"kind(quotes)expletinvalid_val=invalid"value"endletbool=((funs->tryOk(bool_of_strings)withInvalid_argument_->Error(`Msg(Err.invalid_vals(Err.alts["true";"false"])))),Fmt.bool)letparse_witht_of_strexps=tryOk(t_of_strs)withFailure_->Error(`Msg(Err.invalid_valsexp))letint=(parse_withint_of_string"expected an integer",Fmt.int)letstring=((funs->Oks),Fmt.string)letsome(parse,print)=letnone=""in((funs->matchparseswithOkv->Ok(Somev)|Error_ase->e),funppfv->matchvwithNone->Fmt.stringppfnone|Somev->printppfv)leturi=letparses=Ok(Uri.of_strings)inletprintppu=Fmt.stringpp(Uri.to_stringu)in(parse,print)moduleUniv=structtypet=exnletcreate(types)()=letmoduleM=structexceptionEofsoptionendin((funx->M.E(Somex)),functionM.Ex->x|_->None)endtype'akey={id:int;to_univ:'a->Univ.t;of_univ:Univ.t->'aoption;name:string;doc:stringoption;docv:stringoption;docs:stringoption;conv:'aconverter;default:'a;}letnamet=t.nameletdoct=t.docletdocvt=t.docvletdocst=t.docsletconvt=t.convletdefaultt=t.defaultletkey?docs?docv?docnameconvdefault=let()=String.iter(function|'-'|'_'|'a'..'z'|'0'..'9'->()|_->raise@@Invalid_argumentname)nameinletto_univ,of_univ=Univ.create()inletid=Oo.id(objectend)in{id;to_univ;of_univ;name;docs;docv;doc;conv;default}moduleId=structtypet=intletcompare(x:int)(y:int)=comparexyendmoduleM=Map.Make(Id)typet=Univ.tM.tletempty=M.emptyletsingletonkv=M.singletonk.id(k.to_univv)letis_empty=M.is_emptyletmemdk=M.memk.iddletadddkv=M.addk.id(k.to_univv)dletunionrs=M.foldM.addrsletremdk=M.removek.iddletfinddk=tryk.of_univ(M.findk.idd)withNot_found->Noneletgetdk=trymatchk.of_univ(M.findk.idd)withSomev->v|None->raiseNot_foundwithNot_found->k.default(* ~root *)letroot=key~docv:"ROOT"~doc:"The location of the Git repository root."~docs:"COMMON OPTIONS""root"(somestring)None