12345678910111213141516171819202122232425262728includeCmdliner(** existential package of a Term and a setter for a ref to receive the
parsed value *)typearg=Arg:'aTerm.t*('a->unit)->arg(** convert a list of arg packages to a term for the tuple of all the arg
terms, and apply it to a function that sets all the receiver refs *)lettupleargs=letpair(Arg(trm_x,set_x))(Arg(trm_y,set_y))=lettrm_xy=Term.(const(funab->(a,b))$trm_x$trm_y)inletset_xy(a,b)=set_xa;set_ybinArg(trm_xy,set_xy)inletinit=Arg(Term.const(),fun()->())inlet(Arg(trm,set))=Base.List.fold_right~f:pairargs~initinTerm.app(Term.constset)trmletargs:arglistref=ref[]letmk~defaultarg=letvar=refdefaultinletsetx=var:=xinargs:=Arg(arg,set)::!args;varletparseinfovalidate=Cmd.eval_value(Cmd.vinfo(Term.(ret(constvalidate$tuple!args))))