1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768openCmdlinermoduleSyntax=structlet(let+)tf=Term.(constf$t)let(and+)ab=Term.(const(funxy->x,y)$a$b)endopenSyntaxletrecset_current_dirdir=tryOk(Unix.chdirdir)with|Unix.Unix_error(Unix.EINTR,_,_)->set_current_dirdir|Unix.Unix_error(e,_,_)->Error(Unix.error_messagee)letterm=let+log_level=letenv=Arg.env_var"DREAM_VERBOSITY"inLogs_cli.level~docs:Manpage.s_common_options~env()and+dir=letdoc="Run as if $(mname) was started in $(docv) instead of the current \
directory."inArg.(value&opt(somestring)None&info["C"]~docv:"PATH"~doc)inletlevel=matchlog_levelwith|SomeLogs.Info->Some`Info|SomeLogs.App->Some`Info|SomeLogs.Error->Some`Error|SomeLogs.Warning->Some`Warning|SomeLogs.Debug->Some`Debug|None->NoneinDream.initialize_log?level();matchdirwith|None->0|Somedir->(matchset_current_dirdirwith|Ok()->0|Errormsg->Logs.err(funm->m"%s"msg);1)(* Error handling *)lethandle_errors=function|Ok0->ifLogs.err_count()>0then3else0|Okn->n|Error_asr->Logs.on_error_msg~use:(fun_->3)rletexits=Term.exit_info3~doc:"on indiscriminate errors reported on stderr."::Term.default_exits