123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182(*
include Arg
*)exceptionHelpofstringexceptionBadofstringletnot_implemented()=failwith"Stdcompat.Arg is not fully implemented yet. Please fill an issue: https://github.com/thierry-martinez/stdcompat/issues ."typespec=|Unitof(unit->unit)|Boolof(bool->unit)|Setofboolref|Clearofboolref|Stringof(string->unit)|Set_stringofstringref|Intof(int->unit)|Set_intofintref|Floatof(float->unit)|Set_floatoffloatref|Tupleofspeclist|Symbolofstringlist*(string->unit)|Restof(string->unit)|Rest_allof(stringlist->unit)|Expandof(string->stringarray)typekey=stringtypedoc=stringtypeusage_msg=stringtypeanon_fun=string->unitletrecno_expandspec=matchspecwith|Unitf->Arg.Unitf|Boolf->Arg.Boolf|Setr->Arg.Setr|Clearc->Arg.Clearc|Stringf->Arg.Stringf|Set_stringr->Arg.Set_stringr|Intf->Arg.Intf|Set_intr->Arg.Set_intr|Floatf->Arg.Floatf|Set_floatr->Arg.Set_floatr|Tuplel->Arg.Tuple(List.mapno_expandl)|Symbol(l,f)->Arg.Symbol(l,f)|Restf->Arg.Restf|Rest_all_->not_implemented()|Expandf->Expandf(*
| Expand _ -> not_implemented ()
*)letrecexpandspec=matchspecwith|Arg.Unitf->Unitf|Arg.Boolf->Boolf|Arg.Setr->Setr|Arg.Clearc->Clearc|Arg.Stringf->Stringf|Arg.Set_stringr->Set_stringr|Arg.Intf->Intf|Arg.Set_intr->Set_intr|Arg.Floatf->Floatf|Arg.Set_floatr->Set_floatr|Arg.Tuplel->Tuple(List.mapexpandl)|Arg.Symbol(l,f)->Symbol(l,f)|Arg.Restf->Restf|Arg.Expandf->Expandf(*
| Arg.Rest_all f -> Rest_all f
*)letno_expand_listl=List.map(fun(k,s,d)->k,no_expands,d)lletexpand_listl=List.map(fun(k,s,d)->k,expands,d)lletusage_stringlmsg=Arg.usage_string(no_expand_listl)msg(*
let usage_string l msg =
not_implemented ()
*)letalign?limit:_limitl=expand_list(Arg.align(no_expand_listl))(*
let align ?limit:_limit _l =
not_implemented ()
*)letparselanonmsg=Arg.parse(no_expand_listl)anonmsgletparse_argv?currentargvlanonmsg=Arg.parse_argv?currentargv(no_expand_listl)anonmsgletusagelmsg=Arg.usage(no_expand_listl)msgletcurrent=Arg.currentletread_auxtrimsepfile=letchannel=open_in_binfileintryletbuffer=Buffer.create20inletaccu=ref[]inletpush()=lets=Buffer.contentsbufferinlets=iftrim&&s<>""&&s.[String.lengths-1]='\r'thenString.subs0(String.lengths-1)elsesinaccu:=s::!accuintrywhiletruedoletc=input_charchannelinifc=septhenbeginpush();Buffer.clearbufferendelseBuffer.add_charbuffercdone;assertfalsewithEnd_of_file->ifBuffer.lengthbuffer>0thenpush();close_inchannel;Array.of_list(List.rev!accu)withe->close_in_noerrchannel;raiseeletread_arg=read_auxtrue'\n'letread_arg0=read_auxfalse'\x00'letwrite_auxsepfileargs=letchannel=open_out_binfileintryArray.iter(funs->Printf.fprintfchannel"%s%c"ssep)argswithe->close_out_noerrchannel;raiseeletwrite_arg=write_aux'\n'letwrite_arg0=write_aux'\x00'letparse_argv_dynamic?current:_current_=not_implemented()letparse_dynamic_=not_implemented()letparse_expand_=not_implemented()letparse_and_expand_argv_dynamic_=not_implemented()