123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111openCoreopenAsyncopenAsync_smtpmoduleCommand:sigincludemoduletypeofCommandvalrpc:summary:string->?readme:(unit->string)->(Rpc.Connection.t->unitDeferred.t)Param.t->tvalconfigs_or_rpc:summary:string->?readme:(unit->string)->([`ConfigsofSmtp_server.Config.t*Smtp_spool.Config.t|`RpcofRpc.Connection.t]->unitDeferred.t)Param.t->tend=structincludeCommandletrpc_client_command0~host_and_port~f=letopenDeferred.Let_syntaxinmatch%mapRpc.Connection.with_client(Tcp.Where_to_connect.of_host_and_porthost_and_port)(funconn->fconn)with|Oka->a|Errorexn->raiseexn;;letrpc_server_or_configs_flag=letopenCommand.Let_syntaxin[%map_openletrpc_server=flag"rpc-server"(optionalhost_and_port)~doc:"HOST:PORT mailcore instance to query"andserver_config_path=flag"server-config"(optionalFilename.arg_type)~doc:"CONFIG Async_smtp server config file"andspool_config_path=flag"spool-config"(optionalFilename.arg_type)~doc:"CONFIG Async_smtp spool config file"inletserver_config=Option.mapserver_config_path~f:(func->Thread_safe.block_on_async_exn(fun()->Smtp_server.Config.load_exnc))inletspool_config=Option.mapspool_config_path~f:(func->Thread_safe.block_on_async_exn(fun()->Smtp_spool.Config.load_exnc))inletrpc_server=matchrpc_server,server_config,spool_configwith|Somev,(_:Smtp_server.Config.toption),(_:Smtp_spool.Config.toption)->v|None,None,None->failwith"At least one of (-rpc-server) or (-server-config and -spool-config) required"|None,Some_,None|None,None,Some_->failwith"Both -server-config and -spool-config required, or use -rpc-server"|None,Someserver_config,Some_->letport=Smtp_server.Config.rpc_portserver_configinHost_and_port.create~host:"localhost"~portinrpc_server,server_config,spool_config];;letrpc~summary?readmemain=letopenCommand.Let_syntaxinCommand.async~summary?readme[%map_openletmain=mainandrpc_server,_server_config,_spool_config=rpc_server_or_configs_flaginfun()->rpc_client_command0~host_and_port:rpc_server~f:main];;letconfigs_or_rpc~summary?readmemain=letopenCommand.Let_syntaxinCommand.async~summary?readme[%map_openletmain=mainandrpc_server,server_config,spool_config=rpc_server_or_configs_flaginfun()->matchserver_config,spool_configwith|Someserver_config,Somespool_config->main(`Configs(server_config,spool_config))|None,None->rpc_client_command0~host_and_port:rpc_server~f:(funclient->main(`Rpcclient))|_->(* Other cases should be prevented in rpc_server_or_configs_flag *)assertfalse];;end