123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815(**************************************************************************)(* *)(* Copyright 2012-2020 OCamlPro *)(* Copyright 2012 INRIA *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)openOpamTypesopenOpamTypesBaseopenOpamCmdlineropenOpamStd.OpincludeOpamArgTools(** Utils *)letwhen_enum=["always",`Always;"never",`Never;"auto",`Auto]|>List.map(fun(s,v)->cli_original,s,v)letconfirm_enum=[cli_fromcli2_1,"ask",`ask;cli_fromcli2_1,"no",`all_no;cli_fromcli2_1,"yes",`all_yes;cli_fromcli2_1,"unsafe-yes",`unsafe_yes;](* Windows directory separators need to be escaped for manpages *)letdir_sep,escape_path=matchFilename.dir_sepwith|"\\"->letesc="\\\\"inesc,funp->OpamStd.List.concat_mapesc(funx->x)(OpamStd.String.split_delimp'\\')|ds->ds,funx->x(** Opam environment variables *)(* Environment variables that need to be initialised before config init, see
[OpamCliMain.run]. *)letpreinit_environment_variables=letopenOpamStd.Configinletcore=letopenOpamCoreConfig.Ein["DEBUG",(funv->DEBUG(env_intv)),"see options `--debug' and `--debug-level'.";"YES",(funv->YES(env_boolv)),"see options `--yes' and `--confirm-level`. \
$(b,OPAMYES) has priority over $(b,OPAMNO) and is \
ignored if $(b,OPAMCONFIRMLEVEL) is set.";]inletclient=letopenOpamClientConfig.Ein["CLI",(funv->CLI(env_stringv)),"see option `--cli'.";"NOSELFUPGRADE",(funv->NOSELFUPGRADE(env_stringv)),"see option `--no-self-upgrade'";"ROOTISOK",(funv->ROOTISOK(env_boolv)),"don't complain when running as root.";]incore@clientletpreinit_opam_env_variables,doc_opam_env_variables_pre=letpreinit()=OpamStd.Config.E.updates@@List.map(fun(var,cons,_doc)->consvar)preinit_environment_variablesinletdoc=List.map(fun(var,_cons,doc)->`P(Printf.sprintf"$(i,OPAM%s) %s"vardoc))preinit_environment_variablesinpreinit,doc(* Environment variables with their doc and their validity OPAMVAR_var and
OPAMPACKAGE_var are defined and documented static in [help_sections].
*)letenvironment_variables=letopenOpamStd.Configinletcore=letopenOpamCoreConfig.Ein["AUTOANSWER",cli_fromcli2_5,(funv->AUTOANSWER(auto_answerv)),"internal use only.";"COLOR",cli_original,(funv->COLOR(env_whenv)),"when set to $(i,always) or $(i,never), sets a default value for the \
`--color' option.";"CONFIRMLEVEL",cli_fromcli2_1,(funv->CONFIRMLEVEL(env_answerv)),"see option `--confirm-level`. \
$(b,OPAMCONFIRMLEVEL) has priority over $(b,OPAMYES) \
and $(b,OPAMNO).";"DEBUGSECTIONS",cli_fromcli2_1,(funv->DEBUGSECTIONS(env_sectionsv)),"if set, limits debug messages to the space-separated list of \
sections. Sections can optionally have a specific debug level (for \
example, $(b,CLIENT:2) or $(b,CLIENT CUDF:2)), but otherwise use \
`--debug-level'.";"ERRLOGLEN",cli_original,(funv->ERRLOGLEN(env_intv)),"sets the number of log lines printed when a sub-process fails. 0 to \
print all.";"KEEPLOGS",cli_original,(funv->KEEPLOGS(env_boolv)),"tells opam to not remove some temporary command logs and some \
backups. This skips some finalisers and may also help to get more \
reliable backtraces.";"LOGS",cli_original,(funv->LOGS(env_stringv)),("$(i,logdir) sets log directory, default is a temporary directory in \
"^(ifSys.win32then"%TEMP%"else"/tmp"));"MERGEOUT",cli_original,(funv->MERGEOUT(env_boolv)),"merge process outputs, stderr on stdout.";"NO",cli_original,(funv->NO(env_boolv)),"answer no to any question asked, see options `--no` and `--confirm-level`. \
$(b,OPAMNO) is ignored if either $(b,OPAMCONFIRMLEVEL) or $(b,OPAMYES) \
is set.";"PRECISETRACKING",cli_original,(funv->PRECISETRACKING(env_boolv)),"fine grain tracking of directories.";"SAFE",cli_original,(funv->SAFE(env_boolv)),"see option `--safe'.";"STATUSLINE",cli_original,(funv->STATUSLINE(env_whenv)),("display a dynamic status line showing what's currently going on on \
the terminal. (one of "^string_of_enumwhen_enum^")");"USEOPENSSL",cli_betweencli2_0cli2_2,(fun_v->OpamStd.Config.E.REMOVED),"force openssl use for hash computing.";"UTF8",cli_original,(funv->UTF8(env_when_extv)),(Printf.sprintf"use UTF8 characters in output (one of %s). By default \
`auto', which is determined from the locale)."(string_of_enumwhen_enum));"UTF8MSGS",cli_original,(funv->UTF8MSGS(env_boolv)),"use extended UTF8 characters (camels) in opam messages. Implies \
$(i,OPAMUTF8). This is set by default on macOS only.";"VERBOSE",cli_original,(funv->VERBOSE(env_levelv)),"see option `--verbose'.";]inletformat=letopenOpamFormatConfig.Ein["ALLPARENS",cli_original,(funv->ALLPARENS(env_boolv)),"surround all filters with parenthesis.";"SKIPVERSIONCHECKS",cli_original,(funv->SKIPVERSIONCHECKS(env_boolv)),"bypasses some version checks. Unsafe, for compatibility testing only.";"STRICT",cli_original,(funv->STRICT(env_boolv)),"fail on inconsistencies (file reading, switch import, etc.).";]inletsolver=letopenOpamSolverConfig.Ein["BESTEFFORT",cli_original,(funv->BESTEFFORT(env_boolv)),"see option `--best-effort'.";"BESTEFFORTPREFIXCRITERIA",cli_original,(funv->BESTEFFORTPREFIXCRITERIA(env_stringv)),"sets the string that must be prepended to the criteria when the \
`--best-effort' option is set, and is expected to maximise the \
`opam-query' property in the solution.";"CRITERIA",cli_original,(funv->CRITERIA(env_stringv)),"specifies user $(i,preferences) for dependency solving. The default \
value depends on the solver version, use `config report' to know the \
current setting. See also option --criteria.";"CUDFFILE",cli_original,(funv->CUDFFILE(env_stringv)),"save the cudf graph to $(i,file)-actions-explicit.dot.";"CUDFTRIM",cli_original,(funv->CUDFTRIM(env_stringv)),"controls the filtering of unrelated packages during CUDF preprocessing.";"DIGDEPTH",cli_original,(funv->DIGDEPTH(env_intv)),"defines how aggressive the lookup for conflicts during CUDF \
preprocessing is.";"EXTERNALSOLVER",cli_original,(funv->EXTERNALSOLVER(env_stringv)),"see option `--solver'.";"FIXUPCRITERIA",cli_original,(funv->FIXUPCRITERIA(env_stringv)),"same as $(i,OPAMUPGRADECRITERIA), but specific to fixup and reinstall.";"NOASPCUD",cli_original,(funv->NOASPCUD(env_boolv)),"Deprecated.";"PREPRO",cli_original,(funv->PREPRO(env_boolv)),"set this to false to disable CUDF preprocessing. Less efficient, but \
might help debugging solver issue.";"SOLVERALLOWSUBOPTIMAL",cli_fromcli2_1,(funv->SOLVERALLOWSUBOPTIMAL(env_boolv)),"(default `true') allows some solvers to still return a solution when \
they reach timeout; while the solution remains assured to be \
consistent, there is no guarantee in this case that it fits the \
expected optimisation criteria. If `true', opam willcontinue with a \
warning, if `false' a timeout is an error. Currently only \
the builtin-z3 backend handles this degraded case.";"SOLVERTIMEOUT",cli_original,(funv->SOLVERTIMEOUT(env_floatv)),(Printf.sprintf"change the time allowance of the solver. Default is %.1f, set to 0 \
for unlimited. Note that all solvers may not support this option."(OpamStd.Option.default0.OpamSolverConfig.(default.solver_timeout)));"SOLVERTOLERANCE",cli_fromcli2_4,(funv->SOLVERTOLERANCE(env_floatv)),(Printf.sprintf"changes the tolerance towards the solver choosing an unoptimized \
solution (i.e. might pull outdated packages). Typical values range \
from 0.0 (best solution known to the solver) to 1.0 (unoptimized \
solution). Default is %.1f. This option is useful in case the solver \
can't find a solution in a reasonable time \
(see $(b,\\$OPAMSOLVERTIMEOUT)). Note that all solvers may not \
support this option."(OpamStd.Option.default0.OpamSolverConfig.default.solver_tolerance));"UPGRADECRITERIA",cli_original,(funv->UPGRADECRITERIA(env_stringv)),"specifies user $(i,preferences) for dependency solving when performing \
an upgrade. Overrides $(i,OPAMCRITERIA) in upgrades if both are set. \
See also option --criteria.";"USEINTERNALSOLVER",cli_original,(funv->USEINTERNALSOLVER(env_boolv)),"see option `--use-internal-solver'.";"VERSIONLAGPOWER",cli_original,(funv->VERSIONLAGPOWER(env_intv)),"do not use.";]inletrepository=letopenOpamRepositoryConfig.Ein["CURL",cli_original,(funv->CURL(env_stringv)),"can be used to select a given 'curl' program. See $(i,OPAMFETCH) for \
more options.";"FETCH",cli_original,(funv->FETCH(Option.mapOpamShellCommand.of_string(env_stringv))),"specifies how to download files: either `wget', `curl' or a custom \
command where variables $(b,%{url}%), $(b,%{out}%), $(b,%{retry}%), \
$(b,%{compress}%) and $(b,%{checksum}%) will be replaced. Overrides the \
'download-command' value from the main config file.";"NOCHECKSUMS",cli_original,(funv->NOCHECKSUMS(env_boolv)),"enables option --no-checksums when available.";"REPOSITORYTARRING",cli_fromcli2_2,(funb->REPOSITORYTARRING(env_boolb)),"internally store the repositories as tar.gz files. This can be much \
faster on filesystems that don't cope well with scanning large trees \
but have good caching in /tmp. However this is slower in the \
general case.";"REQUIRECHECKSUMS",cli_original,(funv->REQUIRECHECKSUMS(env_boolv)),"Enables option `--require-checksums' when available \
(e.g. for `opam install').";"RETRIES",cli_original,(funv->RETRIES(env_intv)),"sets the number of tries before failing downloads.";"VALIDATIONHOOK",cli_original,(funv->VALIDATIONHOOK(env_stringv)),"if set, uses the `%{hook%}' command to validate \
an opam repository update.";]inletstate=letopenOpamStateConfig.Ein["BUILDDOC",cli_betweencli2_0cli2_1,(funv->BUILDDOC(env_boolv)),"see option `--build-doc'.";"BUILDTEST",cli_betweencli2_0cli2_1,(funv->BUILDTEST(env_boolv)),"see option `--build-test'.";"DOWNLOADJOBS",cli_original,(funv->DOWNLOADJOBS(env_intv)),"sets the maximum number of simultaneous downloads.";"DRYRUN",cli_original,(funv->DRYRUN(env_boolv)),"see option `--dry-run'.";"IGNORECONSTRAINTS",cli_original,(funv->IGNORECONSTRAINTS(env_stringv)),"see install option `--ignore-constraints-on'.";"JOBS",cli_original,(funv->JOBS(env_intv)),"sets the maximum number of parallel workers to run.";"LOCKED",cli_original,(funv->LOCKED(env_stringv)),"combination of `--locked' and `--lock-suffix' options.";"MAKECMD",cli_original,(funv->MAKECMD(env_stringv)),"set the system make command to use.";"NODEPEXTS",cli_fromcli2_1,(funv->NODEPEXTS(env_boolv)),"disables system dependencies handling, see option `--no-depexts'.";"NOENVNOTICE",cli_original,(funv->NOENVNOTICE(env_boolv)),"Internal.";"ROOT",cli_original,(funv->ROOT(env_stringv)),"see option `--root'. This is automatically set \
by `opam env --root=DIR --set-root'.";"SWITCH",cli_original,(funv->SWITCH(env_stringv)),"see option `--switch'. Automatically set \
by `opam env --switch=SWITCH --set-switch'.";"UNLOCKBASE",cli_original,(funv->UNLOCKBASE(env_boolv)),"see install option `--unlock-base'.";"WITHDEVSETUP",cli_fromcli2_2,(funv->WITHDEVSETUP(env_boolv)),"see install option `--with-dev-setup'.";"WITHDOC",cli_original,(funv->WITHDOC(env_boolv)),"see install option `--with-doc'.";"WITHTEST",cli_original,(funv->WITHTEST(env_boolv)),"see install option `--with-test.";]inletclient=letopenOpamClientConfig.Ein["ASSUMEDEPEXTS",cli_fromcli2_1,(funv->ASSUMEDEPEXTS(env_boolv)),"see option `--assume-depexts'.";"AUTOREMOVE",cli_original,(funv->AUTOREMOVE(env_boolv)),"see remove option `--auto-remove'.";"DROPWORKINGDIR",cli_fromcli2_1,(funv->DROPWORKINGDIR(env_boolv)),"overrides packages previously updated with $(b,--working-dir) on \
update. Without this variable set, opam would keep them unchanged \
unless explicitly named on the command-line.";"EDITOR",cli_original,(funv->EDITOR(env_stringv)),"sets the editor to use for opam file editing, overrides $(i,\\$EDITOR) \
and $(i,\\$VISUAL).";"FAKE",cli_original,(funv->FAKE(env_boolv)),"see option `--fake'.";"IGNOREPINDEPENDS",cli_original,(funv->IGNOREPINDEPENDS(env_boolv)),"see option `--ignore-pin-depends'.";"INPLACEBUILD",cli_original,(funv->INPLACEBUILD(env_boolv)),"see option `--inplace-build'.";"JSON",cli_original,(funv->JSON(env_stringv)),"log json output to the given file \
(use character `%' to index the files).";"KEEPBUILDDIR",cli_original,(funv->KEEPBUILDDIR(env_boolv)),"see install option `--keep-build-dir'.";"NOAUTOUPGRADE",cli_original,(funv->NOAUTOUPGRADE(env_boolv)),"disables automatic internal upgrade of repositories in an earlier \
format to the current one, on 'update' or 'init'.";"NOAGGREGATE",cli_original,(funv->NOAGGREGATE(env_boolv)),"with `opam admin check', don't aggregate packages.";"PINKINDAUTO",cli_original,(funv->PINKINDAUTO(env_boolv)),"sets whether version control systems should be detected when pinning \
to a local path. Enabled by default since 1.3.0.";"REUSEBUILDDIR",cli_original,(funv->REUSEBUILDDIR(env_boolv)),"see option `--reuse-build-dir'.";"SHOW",cli_original,(funv->SHOW(env_boolv)),"see option `--show'.";"SKIPUPDATE",cli_original,(funv->SKIPUPDATE(env_boolv)),"see option `--skip-updates'.";"STATS",cli_betweencli2_0cli2_4,(fun_v->OpamStd.Config.E.REMOVED),"display stats at the end of command.";"VERBOSEON",cli_fromcli2_2,(funv->VERBOSEON(env_string_listv)),"see option --verbose-on";"WORKINGDIR",cli_original,(funv->WORKINGDIR(env_boolv)),"see option `--working-dir'.";]incore@format@solver@repository@state@clientletscrubbed_environment_variables=letf(name,validity,_,_)=ifis_original_clivaliditythenNoneelseSome("OPAM"^name)inList.filter_mapfenvironment_variablesletdoc_opam_env_variables,init_opam_env_variabes=env_with_clienvironment_variables(** Help sections common to all commands *)letglobal_option_section=Manpage.s_common_optionslethelp_sectionscli=[`Sglobal_option_section;`P"These options are common to all commands.";`SManpage.s_environment;`P"Opam makes use of the environment variables listed here. Boolean \
variables should be set to \"0\", \"no\", \"false\" or the empty \
string to disable, \"1\", \"yes\" or \"true\" to enable.";]@List.sortcompare(doc_opam_env_variables_pre@doc_opam_env_variablescli)@[`P"$(i,OPAMVAR_var) overrides the contents of the variable $(i,var) when \
substituting `%{var}%` strings in `opam` files.";`P"$(i,OPAMVAR_package_var) overrides the contents of the variable \
$(i,package:var) when substituting `%{package:var}%` strings in \
`opam` files.";`S"CLI VERSION";`P"All scripts and programmatic invocations of opam should use `--cli' in \
order to ensure that they work seamlessly with future versions of the \
opam client. Additionally, blog posts or other documentation can \
benefit, as it prevents information from becoming stale.";`P(Printf.sprintf"Although opam only supports roots ($(i,~%s.opam%s)) for the current \
version, it does provide backwards compatibility for its \
command-line interface."dir_sepdir_sep);`P"Since CLI version support was only added in opam 2.1, use $(i,OPAMCLI) \
to select 2.0 support (as opam 2.0 will just ignore it), \
and `--cli=2.1' for 2.1 (or later) versions, since an environment variable \
controlling the parsing of syntax is brittle. To this end, opam \
displays a warning if $(i,OPAMCLI) specifies a valid version other \
than 2.0, and also if `--cli=2.0' is specified.";`P"The command-line version is selected by using the `--cli' option or \
the $(i,OPAMCLI) environment variable. `--cli' may be specified more\
than once, where the last instance takes precedence. $(i,OPAMCLI) is \
only inspected if `--cli' is not given.";`SManpage.s_exit_status;`P"As an exception to the following, the `exec' command returns 127 if the \
command was not found or couldn't be executed, and the command's exit \
value otherwise."]@List.map(fun(reason,code)->`I(string_of_intcode,matchreasonwith|`Success->"Success, or true for boolean queries."|`False->"False. Returned when a boolean return value is expected, e.g. when \
running with $(b,--check), or for queries like $(b,opam lint)."|`Bad_arguments->"Bad command-line arguments, or command-line arguments pointing to \
an invalid context (e.g. file not following the expected format)."|`Not_found->"Not found. You requested something (package, version, repository, \
etc.) that couldn't be found."|`Aborted->"Aborted. The operation required confirmation, which wasn't given."|`Locked->"Could not acquire the locks required for the operation."|`No_solution->"There is no solution to the user request. This can be caused by \
asking to install two incompatible packages, for example."|`File_error->"Error in package definition, or other metadata files. Using \
$(b,--strict) raises this error more often."|`Package_operation_error->"Package script error. Some package operations were unsuccessful. \
This may be an error in the packages or an incompatibility with \
your system. This can be a partial error."|`Sync_error->"Sync error. Could not fetch some remotes from the network. This can \
be a partial error."|`Configuration_error->"Configuration error. Opam or system configuration doesn't allow \
operation, and needs fixing."|`Solver_failure->"Solver failure. The solver failed to return a sound answer. It can \
be due to a broken external solver, or an error in solver \
configuration."|`Internal_error->"Internal error. Something went wrong, likely due to a bug in opam \
itself."|`User_interrupt->"User interrupt. SIGINT was received, generally due to the user \
pressing Ctrl-C."))OpamStd.Sys.exit_codes@[`S"FURTHER DOCUMENTATION";`P(Printf.sprintf"See https://opam.ocaml.org/doc.");`SManpage.s_authors;`P"David Allsopp <david@tarides.com>";`Noblank;`P"Vincent Bernardoff <vb@luminar.eu.org>";`Noblank;`P"Raja Boujbel <raja.boujbel@ocamlpro.com>";`Noblank;`P"Kate Deplaix <kit-ty-kate@outlook.com>";`Noblank;`P"Roberto Di Cosmo <roberto@dicosmo.org>";`Noblank;`P"Thomas Gazagnaire <thomas@gazagnaire.org>";`Noblank;`P"Louis Gesbert <louis.gesbert@ocamlpro.com>";`Noblank;`P"Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>";`Noblank;`P"Anil Madhavapeddy <anil@recoil.org>";`Noblank;`P"Guillem Rieu <guillem.rieu@ocamlpro.com>";`Noblank;`P"Ralf Treinen <ralf.treinen@pps.jussieu.fr>";`Noblank;`P"Frederic Tuong <tuong@users.gforge.inria.fr>";`SManpage.s_bugs;`P"Check bug reports at https://github.com/ocaml/opam/issues.";](** Global options *)typeglobal_options={debug_level:intoption;verbose:int;quiet:bool;color:OpamStd.Config.when_option;opt_switch:stringoption;confirm_level:OpamStd.Config.answeroption;yes:booloption;strict:bool;opt_root:dirnameoption;git_version:bool;external_solver:stringoption;use_internal_solver:bool;cudf_file:stringoption;solver_preferences:stringoption;best_effort:bool;safe_mode:bool;json:stringoption;no_auto_upgrade:bool;working_dir:bool;ignore_pin_depends:bool;cli:OpamCLIVersion.t;}(* The --cli passed by opam-core.cmdliner is ignored (it's only there for --help) *)letcreate_global_optionsgit_versiondebugdebug_levelverbosequietcoloropt_switchyesconfirm_levelstrictopt_rootexternal_solveruse_internal_solvercudf_filesolver_preferencesbest_effortsafe_modejsonno_auto_upgradeworking_dirignore_pin_dependsd_no_aspcud_=ifd_no_aspcudthenOpamConsole.warning"Option %s is deprecated, ignoring it."(OpamConsole.colorise`bold"--no-aspcud");letdebug_level=OpamStd.Option.Op.(debug_level>>+fun()->ifdebugthenSome1elseNone)inletget_lastl=matchList.revlwith[]->None|x::_->Somexinletyes=get_lastyesinletconfirm_level=get_lastconfirm_levelinletverbose=List.lengthverboseinletcli=OpamCLIVersion.currentin{git_version;debug_level;verbose;quiet;color;opt_switch;confirm_level;yes;strict;opt_root;external_solver;use_internal_solver;cudf_file;solver_preferences;best_effort;safe_mode;json;no_auto_upgrade;working_dir;ignore_pin_depends;cli}letapply_global_optionsclio=ifo.git_versionthen(beginmatchOpamGitVersion.versionwith|None->()|Somev->OpamConsole.msg"%s\n"vend;OpamStd.Sys.exit_because`Success);letopenOpamStd.Option.Opinletflagf=iffthenSometrueelseNoneinletsomex=matchxwithNone->None|some->Somesomeinletsolver=ifo.use_internal_solverthenSome(lazy(OpamCudfSolver.get_solver~internal:trueOpamCudfSolver.default_solver_selection))elseo.external_solver>>|funs->lazy(OpamCudfSolver.solver_of_strings)inletsolver_prefs=o.solver_preferences>>|funp->lazy(Somep)inletyes=Stdlib.Option.mapStdlib.Option.someo.yesininit_opam_env_variabescli;OpamClientConfig.opam_init(* - format options - *)?strict:(flago.strict)(* ?skip_version_checks:bool *)(* ?all_parens:bool *)(* - core options - *)?debug_level:(matcho.debug_levelwith|Somexwhenx<0->o.debug_level|_->ifo.safe_modethenSome0elseo.debug_level)?verbose_level:(ifo.quietthenSome0elseifo.verbose=0thenNoneelseSomeo.verbose)?color:o.color(* ?utf8:[ `Extended | `Always | `Never | `Auto ] *)(* ?disp_status_line:[ `Always | `Never | `Auto ] *)?confirm_level:o.confirm_level?yes?safe_mode:(flago.safe_mode)(* ?cygbin:string option *)(* ?lock_retries:int *)(* ?log_dir:OpamTypes.dirname *)(* ?keep_log_dir:bool *)(* - repository options - *)(* ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t *)(* ?retries:int *)(* ?force_checksums:bool option *)(* - solver options *)?cudf_file:(someo.cudf_file)?solver?best_effort:(flago.best_effort)?solver_preferences_default:solver_prefs?solver_preferences_upgrade:solver_prefs?solver_preferences_fixup:solver_prefs(* ?solver_preferences_best_effort_prefix: *)(* - state options - *)?root_dir:o.opt_root?original_root_dir:o.opt_root?current_switch:(o.opt_switch>>|OpamSwitch.of_string)?switch_from:(o.opt_switch>>|fun_->`Command_line)(* ?jobs: int *)(* ?dl_jobs: int *)(* ?keep_build_dir:bool *)(* ?build_test:bool *)(* ?build_doc:bool *)(* ?show:bool *)(* ?dryrun:bool *)(* ?fake:bool *)(* ?makecmd:string Lazy.t *)(* ?ignore_constraints_on:name_set *)(* ?skip_dev_update:bool *)?json_out:OpamStd.Option.Op.(o.json>>|function""->None|s->Somes)(* ?root_is_ok:bool *)?no_auto_upgrade:(flago.no_auto_upgrade)(* - client options - *)?working_dir:(flago.working_dir)?ignore_pin_depends:(flago.ignore_pin_depends)(* ?sync_archives:bool *)(* ?pin_kind_auto:bool *)(* ?autoremove:bool *)(* ?editor:string *)~cli:o.cli();ifOpamClientConfig.(!r.json_out<>None)then(OpamJson.append"opam-version"(`StringOpamVersion.(to_string(full())));OpamJson.append"command-line"(`A(List.map(funs->`Strings)(Array.to_listSys.argv))));(* We need to retrieve very early cygwin root path to set up 'cygbin' config
field and git binary path.
It is retrieved from config file, and we use a low level reading of
that file instead of OpamStateConfig.safe_load to avoid multiple error
messages displayed if an error is detected in the config file. If there is
an error, or best effort notification, it will be highlighted after
anyway. *)tryletopamfile=OpamPath.configOpamStateConfig.(!r.root_dir)|>OpamFile.to_string|>OpamParser.FullPos.fileinList.iterOpamParserTypes.FullPos.(function|{pelem=Variable({pelem="sys-pkg-manager-cmd";_},{pelem=List{pelem=elements;_};_});_}->letrecauxlastelements=matchlast,elementswith|_,[]->()|Some{pelem=String"cygwin";_},{pelem=Stringcygcheck;_}::_->letcygbin=Filename.dirnamecygcheckinOpamCoreConfig.update~cygbin()|_,element::elements->aux(Someelement)elementsinauxNoneelements|{pelem=Variable({pelem="global-variables";_},{pelem=List{pelem=elements;_};_});_}->letrecauxlastelements=matchlast,elementswith|_,[]->()|Some{pelem=Ident"os-distribution";_},{pelem=String"msys2";_}::_->letcygbin=Stdlib.Option.mapFilename.dirname(OpamSystem.resolve_command"cygcheck")inOpamCoreConfig.update?cygbin()|_,element::elements->aux(Someelement)elementsinauxNoneelements|{pelem=Variable({pelem="git-location";_},{pelem=Stringgit_location;_});_}->OpamCoreConfig.update~git_location()|_->())opamfile.file_contentswith|Sys_error_|Not_found->()(** Build options *)typebuild_options={keep_build_dir:bool;reuse_build_dir:bool;inplace_build:bool;make:stringoption;no_checksums:bool;req_checksums:bool;build_test:bool;build_doc:bool;dev_setup:bool;show:bool;dryrun:bool;fake:bool;skip_update:bool;jobs:intoption;ignore_constraints_on:namelistoption;unlock_base:bool;locked:bool;lock_suffix:string;assume_depexts:bool;no_depexts:bool;verbose_on:namelistoption;}letcreate_build_optionskeep_build_dirreuse_build_dirinplace_buildmakeno_checksumsreq_checksumsbuild_testbuild_docdev_setupshowdryrunskip_updatefakejobsignore_constraints_onunlock_baselockedlock_suffixassume_depextsno_depextsverbose_on={keep_build_dir;reuse_build_dir;inplace_build;make;no_checksums;req_checksums;build_test;build_doc;dev_setup;show;dryrun;skip_update;fake;jobs;ignore_constraints_on;unlock_base;locked;lock_suffix;assume_depexts;no_depexts;verbose_on;}letapply_build_optionsclib=letopenOpamStd.Option.Opinletflagf=iffthenSometrueelseNoneinOpamRepositoryConfig.update(* ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t *)(* ?retries:int *)?force_checksums:(ifb.req_checksumsthenSome(Sometrue)elseifb.no_checksumsthenSome(Somefalse)elseNone)();OpamStateConfig.update(* ?root: -- handled globally *)?jobs:(b.jobs>>|funj->lazyj)(* ?dl_jobs:int *)(* ?no_base_packages:(flag o.no_base_packages) -- handled globally *)?build_test:(flagb.build_test)?build_doc:(flagb.build_doc)?dev_setup:(flagb.dev_setup)?dryrun:(flagb.dryrun)?makecmd:(b.make>>|funm->lazym)?ignore_constraints_on:(b.ignore_constraints_on>>|OpamPackage.Name.Set.of_list)?unlock_base:(flagb.unlock_base)?locked:(ifb.lockedthenSome(Someb.lock_suffix)elseNone)?no_depexts:(flag(b.no_depexts||OpamCLIVersion.Op.(cli@=cli2_0)))();OpamClientConfig.update?keep_build_dir:(flagb.keep_build_dir)?reuse_build_dir:(flagb.reuse_build_dir)?inplace_build:(flagb.inplace_build)?show:(flagb.show)?fake:(flagb.fake)?skip_dev_update:(flagb.skip_update)?assume_depexts:(flag(b.assume_depexts||b.no_depexts))?verbose_on:(b.verbose_on>>=function|[]->None|vo->Some(OpamPackage.Name.Set.of_listvo))~scrubbed_environment_variables()(** Converters *)letpr_str=Format.pp_print_stringletrepository_name=letparsestr=`Ok(OpamRepositoryName.of_stringstr)inletprintppfname=pr_strppf(OpamRepositoryName.to_stringname)inparse,printleturl=letparsestr=matchOpamUrl.parse_opt~from_file:falsestrwith|Someurl->`Okurl|None->`Error("malformed url "^str)inletprintppfurl=pr_strppf(OpamUrl.to_stringurl)inparse,printletfilename=letparsestr=`Ok(OpamFilename.of_stringstr)inletprintppffilename=pr_strppf(OpamFilename.to_stringfilename)inparse,printletexisting_filename_or_dash=letparsestr=ifstr="-"then`OkNoneelseletf=OpamFilename.of_stringstrinifOpamFilename.existsfthen`Ok(Somef)else`Error(Printf.sprintf"File %s not found"(OpamFilename.to_stringf))inletprintppffilename=pr_strppfOpamStd.Option.Op.((filename>>|OpamFilename.to_string)+!"-")inparse,printletdirname=letparsestr=`Ok(OpamFilename.Dir.of_stringstr)inletprintppfdir=pr_strppf(escape_path(OpamFilename.prettify_dirdir))inparse,printletexisting_filename_dirname_or_dash=letparsestr=ifstr="-"then`OkNoneelsematchOpamFilename.opt_file(OpamFilename.of_stringstr)with|Somef->`Ok(Some(OpamFilename.Ff))|None->matchOpamFilename.opt_dir(OpamFilename.Dir.of_stringstr)with|Somed->`Ok(Some(OpamFilename.Dd))|None->`Error(Printf.sprintf"File or directory %s not found"str)inletprintppfgf=pr_strppf@@matchgfwith|None->"-"|Some(OpamFilename.Dd)->OpamFilename.Dir.to_stringd|Some(OpamFilename.Ff)->OpamFilename.to_stringfinparse,printletsubpath_conv=letparsestr=`Ok(OpamFilename.SubPath.of_stringstr)inletprintppfsb=pr_strppf(OpamFilename.SubPath.to_stringsb)inparse,printletpackage_name=letparsestr=try`Ok(OpamPackage.Name.of_stringstr)withFailuremsg->`Errormsginletprintppfpkg=pr_strppf(OpamPackage.Name.to_stringpkg)inparse,printletpackage_version=letparsestr=try`Ok(OpamPackage.Version.of_stringstr)withFailuremsg->`Errormsginletprintppfver=pr_strppf(OpamPackage.Version.to_stringver)inparse,printletpositive_integer:intArg.conv=let(parser,printer)=Arg.intinletparsers=matchparserswith|`Error_->`Error"expected a strictly positive integer"|`Oknasr->ifn<=0then`Error"expected a positive integer"elserin(parser,printer)(* name * version option *)letpackage=letparsestr=letre=Re.(compile@@seq[bos;group@@rep1@@diffany(set">=<.!");opt@@seq[set".=";group@@rep1any];eos;])intryletsub=Re.execrestrinletname=OpamPackage.Name.of_string(Re.Group.getsub1)inletversion_opt=trySome(OpamPackage.Version.of_string(Re.Group.getsub2))withNot_found->Nonein`Ok(name,version_opt)withNot_found|Failure_->`Error"bad package format"inletprintppf(name,version_opt)=matchversion_optwith|None->pr_strppf(OpamPackage.Name.to_stringname)|Somev->pr_strppf(OpamPackage.Name.to_stringname^"."^OpamPackage.Version.to_stringv)inparse,printletpackage_with_version=letparsestr=matchfstpackagestrwith|`Ok(n,Somev)->`Ok(OpamPackage.createnv)|`Ok(_,None)->`Error"missing package version"|`Errore->`Erroreinletprintppfnv=pr_strppf(OpamPackage.to_stringnv)inparse,print(* name * version constraint *)letatom=letparsestr=try`Ok(OpamFormula.atom_of_stringstr)withFailuremsg->`Errormsginletprintppfatom=pr_strppf(OpamFormula.short_string_of_atomatom)inparse,printletatom_or_local=letparsestr=ifOpamStd.String.contains~sub:Filename.dir_sepstr||OpamCompat.String.starts_with~prefix:"."strthenifOpamFilename.(exists(of_stringstr))then`Ok(`Filename(OpamFilename.of_stringstr))elseifOpamFilename.(exists_dir(Dir.of_stringstr))then`Ok(`Dirname(OpamFilename.Dir.of_stringstr))else`Error(Printf.sprintf"Not a valid package specification or existing file or \
directory: %s"str)elsematchfstatomstrwith|`Okat->`Ok(`Atomat)|`Errore->`Erroreinletprintppf=function|`Filenamef->pr_strppf(OpamFilename.to_stringf)|`Dirnamed->pr_strppf(OpamFilename.Dir.to_stringd)|`Atoma->sndatomppfainparse,printletatom_or_dir=letparsestr=matchfstatom_or_localstrwith|`Ok(`Filename_)->`Error(Printf.sprintf"Not a valid package specification or existing directory: %s"str)|`Ok(`Atom_|`Dirname_asatom_or_dir)->`Ok(atom_or_dir)|`Errore->`Erroreinletprintppf=sndatom_or_localppfinparse,printletdep_formula=letmoduleOpamParser=OpamParser.FullPosinletmoduleOpamPrinter=OpamPrinter.FullPosinletpp=OpamFormat.V.(package_formula`Conj(constraintsversion))inletparsestr=tryletv=OpamParser.value_from_stringstr"<command-line>"in`Ok(OpamPp.parsepp~pos:pos_nullv)withe->OpamStd.Exn.fatale;`Error(Printexc.to_stringe)inletprintppff=pr_strppf(OpamPrinter.value(OpamPp.printppf))inparse,printletvariable_bindings=letparsestr=tryOpamStd.String.splitstr','|>List.map(funs->matchOpamStd.String.cut_ats'='with|Some(a,b)->OpamVariable.of_stringa,b|None->Printf.ksprintffailwith"%S is not a binding"s)|>funbnds->`OkbndswithFailuree->`Erroreinletprintppfx=List.map(fun(a,b)->Printf.sprintf"%s=%s"(OpamVariable.to_stringa)b)x|>String.concat","|>pr_strppfinparse,printletwarn_selector=letparsestr=letsep=Re.(compile(set"+-@"))inletsel=Re.(compile@@seq[bos;group(rep1digit);opt@@seq[str"..";group(rep1digit)];eos])inletrecseqij=ifInt.equalijthen[i]elseifi<jtheni::seq(i+1)jelsej::seq(j+1)iinletrecauxacc=function|`Delimd::`Textn::r->letnums=letg=Re.execselninleti=int_of_string(Re.Group.getg1)intryseqi(int_of_string(Re.Group.getg2))withNot_found->[i]inletstate=matchRe.Group.getd0with|"+"->`Enable|"-"->`Disable|"@"->`EnableError|_->assertfalseinletacc=List.fold_left(funaccn->(n,state)::acc)accnumsinauxaccr|[]->acc|_->raiseNot_foundintry`Ok(List.rev(aux[](Re.split_fullsepstr)))withNot_found->`Error"Expected a warning string, e.g. '--warn=-10..21+12-36'"inletprintppfwarns=pr_strppf@@OpamStd.List.concat_map""(fun(num,state)->letstate=matchstatewith|`Enable->'+'|`Disable->'-'|`EnableError->'@'inPrintf.sprintf"%c%d"statenum)warnsinparse,printlet_selector=letparsestr=letr=List.fold_left(fun(plus,minus)elem->matchOpamStd.String.sub_at1elemwith|"+"asprefix->(OpamStd.String.remove_prefix~prefixelem)::plus,minus|"-"asprefix->plus,(OpamStd.String.remove_prefix~prefixelem)::minus|_->elem::plus,minus)([],[])(OpamStd.String.splitstr',')in`Okrinletprintppf(plus,minus)=letconcatc=OpamStd.List.concat_map~nil:""","(funx->c^x)inpr_strppf@@Printf.sprintf"%s,%s"(concat"+"plus)(concat"-"minus)inparse,print(* unused
let enum_with_default sl: 'a Arg.converter =
let parse, print = Arg.enum sl in
let parse s =
match parse s with
| `Ok _ as x -> x
| _ -> `Ok (`default s) in
parse, print
*)letopamlist_column=letparsestr=ifOpamCompat.String.ends_with~suffix:":"strthenletfld=OpamStd.String.remove_suffix~suffix:":"strin`Ok(OpamListCommand.Fieldfld)elsetryList.find(function(OpamListCommand.Field_),_->false|_,name->name=str)OpamListCommand.field_names|>fun(f,_)->`OkfwithNot_found->`Error(Printf.sprintf"No known printer for column %s. If you meant an opam file \
field, use '%s:' instead (with a trailing colon)."strstr)inletprintppffield=Format.pp_print_stringppf(OpamListCommand.string_of_fieldfield)inparse,printletopamlist_columns=letfield_re=(* max paren nesting 1, obviously *)Re.(compile@@seq[start;group@@seq[rep@@diffany(set",(");opt@@seq[char'(';rep(diffany(char')'));char')'];];alt[char',';stop];])inletparsestr=tryletrecauxpos=ifpos=String.lengthstrthen[]elseletg=Re.exec~posfield_restrinRe.Group.getg1::aux(Re.Group.stopg0)inletfields=aux0inList.fold_left(function|`Error_ase->fun_->e|`Okacc->funstr->matchfstopamlist_columnstrwith|`Okf->`Ok(acc@[f])|`Error_ase->e)(`Ok[])fieldswithNot_found->`Error(Printf.sprintf"Invalid columns specification: '%s'."str)inletprintppfcols=letrecaux=function|x::(_::_)asr->sndopamlist_columnppfx;Format.pp_print_charppf',';auxr|[x]->sndopamlist_columnppfx|[]->()inauxcolsinparse,printlethash_kinds=Arg.enum(List.map(funk->OpamHash.string_of_kindk,k)OpamHash.all_kinds)letmk_flag~clivalidity?(section=Manpage.s_options)flagsname=mk_flag~clivalidity~sectionflagsnameletmk_flag_replaced~cli?(section=Manpage.s_options)flagsdoc=mk_flag_replaced~cli~sectionflagsdocletmk_opt~clivalidity?(section=Manpage.s_options)?voptflagsvaluedockinddefault=mk_opt~clivalidity~section?voptflagsvaluedockinddefaultletmk_opt_all~clivalidity?(section=Manpage.s_options)?vopt?defaultflagsvaluedockind=mk_opt_all~clivalidity~section?vopt?defaultflagsvaluedockindletmk_vflag~cli?(section=Manpage.s_options)defaultflags=mk_vflag~cli~sectiondefaultflagsletmk_vflag_all~cli?(section=Manpage.s_options)?defaultflags=mk_vflag_all~cli~section?defaultflagsletmk_enum_opt~clivalidity?(section=Manpage.s_options)flagsvaluestatesdoc=mk_enum_opt~clivalidity~sectionflagsvaluestatesdocletterm_info~clititle~doc~man=letman=man@help_sectionscliinCmd.info~sdocs:global_option_section~docs:Manpage.s_commands~doc~mantitleletmk_command~clivalidityname~doc~man=mk_command~clivalidityterm_infoname~doc~manletmk_command_ret~clivalidityname~doc~man=mk_command_ret~clivalidityterm_infoname~doc~manletmake_command_alias~clicmd?(options="")name=letterm,info=cmdin(* TODO: Remove that horror whenever https://github.com/dbuenzli/cmdliner/pull/161 is merged *)letname_of_new_api_infoinfo=Cmd.name(Cmd.vinfo(Term.const()))inletorig=name_of_new_api_infoinfoinletdoc=Printf.sprintf"An alias for $(b,%s%s)."origoptionsinletman=[`SManpage.s_description;`P(Printf.sprintf"$(mname)$(b, %s) is an alias for $(mname)$(b, %s%s)."nameorigoptions);`P(Printf.sprintf"See $(mname)$(b, %s --help) for details."orig);`SManpage.s_options;]@help_sectionscliinterm,Cmd.infoname~docs:"COMMAND ALIASES"~sdocs:global_option_section~doc~manletarg_listnamedockind=letdoc=Arg.info~docv:name~doc[]inArg.(value&pos_allkind[]&doc)letnonempty_arg_listnamedockind=letdoc=Arg.info~docv:name~doc[]inArg.(non_empty&pos_allkind[]&doc)(** Common flags *)letprint_short_flag?sectionclivalidity=mk_flag~clivalidity?section["s";"short"]"Output raw lists of names, one per line, skipping any details."letshell_opt?sectionclivalidity=letenum=[None,"bash",SH_bash;None,"sh",SH_sh;None,"csh",SH_csh;None,"zsh",SH_zsh;None,"fish",SH_fish;Somecli2_2,"pwsh",SH_pwshPowershell_pwsh;Somecli2_2,"cmd",SH_cmd;Somecli2_2,"powershell",SH_pwshPowershell]|>List.map(fun(c,s,v)->OpamStd.Option.map_defaultcli_fromcli_originalc,s,v)inmk_enum_opt~clivalidity?section["shell"]"SHELL"enum(Printf.sprintf"Sets the configuration mode for opam environment appropriate for \
$(docv). One of %s. Guessed from the parent processes and the \\$SHELL \
variable by default."(string_of_enumenum))letdot_profile_flag?sectionclivalidity=mk_opt~clivalidity?section["dot-profile"]"FILENAME"(Printf.sprintf"Name of the configuration file to update instead of \
$(i,~%s.profile) or $(i,~%s.zshrc) based on shell detection."dir_sepdir_sep)(Arg.somefilename)Noneletrepo_kind_flag?sectionclivalidity=letmain_kinds=["http",`http;"local",`rsync;"git",`git;"darcs",`darcs;"hg",`hg;]|>List.map(fun(s,v)->cli_original,s,v)inletaliases_kinds=["wget",`http;"curl",`http;"rsync",`rsync;]|>List.map(fun(s,v)->cli_original,s,v)inmk_enum_opt~clivalidity?section["k";"kind"]"KIND"(main_kinds@aliases_kinds)(Printf.sprintf"Specify the kind of the repository to be used (%s)."(string_of_enummain_kinds))letjobs_flag?sectionclivalidity=mk_opt~clivalidity?section["j";"jobs"]"JOBS""Set the maximal number of concurrent jobs to use. The default value is \
calculated from the number of cores. You can also set it using the \
$(b,\\$OPAMJOBS) environment variable."Arg.(somepositive_integer)Noneletformula_flag?sectioncli=mk_opt~cli(cli_from~experimental:truecli2_2)?section["formula"]"FORMULA""Specify a dependency formula to be verified by the solution, in addition \
to the switch invariant. The format is the same as for expressing \
dependencies in package definition files, e.g. '\"foo\" {>= \"1.1\"}'"dep_formulaOpamFormula.Emptyletname_list=arg_list"PACKAGES""List of package names."package_nameletatom_list=arg_list"PACKAGES""List of package names, with an optional version or constraint, \
e.g `pkg', `pkg.1.0' or `pkg>=0.5'."atomletatom_or_local_list=arg_list"PACKAGES"(Printf.sprintf"List of package names, with an optional version or constraint, e.g `pkg', \
`pkg.1.0' or `pkg>=0.5' ; or files or directory names containing package \
description, with explicit directory (e.g. `.%sfoo.opam' or `.')"dir_sep)atom_or_localletatom_or_dir_list=arg_list"PACKAGES"(Printf.sprintf"List of package names, with an optional version or constraint, e.g `pkg', \
`pkg.1.0' or `pkg>=0.5' ; or directory names containing package \
description, with explicit directory (e.g. `.%ssrcdir' or `.')"dir_sep)atom_or_dirletnonempty_atom_list=nonempty_arg_list"PACKAGES""List of package names, with an optional version or constraint, \
e.g `pkg', `pkg.1.0' or `pkg>=0.5'."atomletparam_list=arg_list"PARAMS""List of parameters."Arg.string(* Options common to all commands *)letglobal_optionscli=letsection=global_option_sectioninletgit_version=mk_flag~clicli_original~section["git-version"]"Print the git version of opam, if set (i.e. you are using a development \
version), and exit."inletdebug=mk_flag~clicli_original~section["debug"]"Print debug message to stderr. \
This is equivalent to setting $(b,\\$OPAMDEBUG) to \"true\"."inletdebug_level=mk_opt~clicli_original~section["debug-level"]"LEVEL""Like $(b,--debug), but allows specifying the debug level ($(b,--debug) \
sets it to 1). Equivalent to setting $(b,\\$OPAMDEBUG) to a positive \
integer."Arg.(someint)Noneinletverbose=Arg.(value&flag_all&info~docs:section["v";"verbose"]~doc:"Be more verbose. One $(b,-v) shows all package commands, repeat to \
also display commands called internally (e.g. $(i,tar), $(i,curl), \
$(i,patch) etc.) Repeating $(i,n) times is equivalent to setting \
$(b,\\$OPAMVERBOSE) to \"$(i,n)\".")inletquiet=mk_flag~clicli_original~section["q";"quiet"]"Disables $(b,--verbose)."inletcolor=mk_enum_opt~clicli_original~section["color"]"WHEN"when_enum(Printf.sprintf"Colorize the output. $(docv) must be %s."(string_of_enumwhen_enum))in(* The --cli option is pre-processed, because it has to be able to appear
before sub-commands. The one here is present only for --help. *)letcli_arg=mk_opt~clicli_original~section["cli"]"MAJOR.MINOR""Use the command-line interface syntax and semantics of $(docv). \
Intended for any persistent use of opam (scripts, blog posts, etc.), \
any version of opam in the same MAJOR series will behave as for the \
specified MINOR release. The flag was not available in opam 2.0, so to \
select the 2.0 CLI, set the $(b,OPAMCLI) environment variable to \
$(i,2.0) instead of using this parameter."Arg.string(OpamCLIVersion.to_stringOpamCLIVersion.current)inletswitch=mk_opt~clicli_original~section["switch"]"SWITCH""Use $(docv) as the current compiler switch. \
This is equivalent to setting $(b,\\$OPAMSWITCH) to $(i,SWITCH)."Arg.(somestring)Noneinletyes=mk_vflag_all~cli~section[cli_original,true,["y";"yes"],"Answer yes to all opam yes/no questions without prompting. \
See also $(b,--confirm-level). \
This is equivalent to setting $(b,\\$OPAMYES) to \"true\".";cli_fromcli2_1,false,["no"],"Answer no to all opam yes/no questions without prompting. \
See also $(b,--confirm-level). \
This is equivalent to setting $(b,\\$OPAMNO) to \"true\".";]inletconfirm_level=mk_enum_opt_all~cli(cli_fromcli2_1)~section["confirm-level"]"LEVEL"confirm_enum(Printf.sprintf"Confirmation level, $(docv) must be %s. Can be specified more than \
once. If $(b,--yes) or $(b,--no) are also given, the value of the \
last $(b,--confirm-level) is taken into account. This is equivalent \
to setting $(b, \\$OPAMCONFIRMLEVEL)`."(string_of_enumconfirm_enum))inletstrict=mk_flag~clicli_original~section["strict"]"Fail whenever an error is found in a package definition \
or a configuration file. The default is to continue silently \
if possible."inletroot=mk_opt~clicli_original~section["root"]"ROOT""Use $(docv) as the current root path. \
This is equivalent to setting $(b,\\$OPAMROOT) to $(i,ROOT)."Arg.(somedirname)Noneinletd_no_aspcud=mk_flag~cli(cli_betweencli2_0cli2_1)~section["no-aspcud"]"Deprecated"inletuse_internal_solver=mk_flag~clicli_original~section["use-internal-solver"]"Disable any external solver, and use the built-in one (this requires \
that opam has been compiled with a built-in solver). This is equivalent \
to setting $(b,\\$OPAMNOASPCUD) or $(b,\\$OPAMUSEINTERNALSOLVER)."inletexternal_solver=mk_opt~clicli_original~section["solver"]"CMD"(Printf.sprintf"Specify the CUDF solver to use for resolving package installation \
problems. This is either a predefined solver (this version of opam \
supports %s), or a custom command that should contain the variables \
%%{input}%%, %%{output}%%, %%{criteria}%%, and optionally \
%%{timeout}%%. This is equivalent to setting $(b,\\$OPAMEXTERNALSOLVER)."(OpamStd.List.concat_map", "(fun(moduleS:OpamCudfSolver.S)->S.name)(OpamCudfSolver.default_solver_selection)))Arg.(somestring)Noneinletsolver_preferences=mk_opt~clicli_original~section["criteria"]"CRITERIA"("Specify user $(i,preferences) for dependency solving for this run. \
Overrides $(b,\\$OPAMCRITERIA), $(b,\\$OPAMFIXUPCRITERIA) and $(b,\\$OPAMUPGRADECRITERIA). \
For details on the supported language, and the external solvers available, see \
$(i, http://opam.ocaml.org/doc/External_solvers.html). \
A general guide to using solver preferences can be found at \
$(i, http://www.dicosmo.org/Articles/usercriteria.pdf).")Arg.(somestring)Noneinletcudf_file=mk_opt~clicli_original~section["cudf"]"FILENAME""Debug option: Save the CUDF requests sent to the solver to \
$(docv)-<n>.cudf where <n> is the n-th call to the solver during \
the opam run."Arg.(somestring)Noneinletbest_effort=mk_flag~clicli_original~section["best-effort"]"Don't fail if all requested packages can't be installed: try to install \
as many as possible. Note that not all external solvers may support \
this option (recent versions of $(i,aspcud) or $(i,mccs) should). This \
is equivalent to setting $(b,\\$OPAMBESTEFFORT) environment variable."inletsafe_mode=mk_flag~clicli_original~section["readonly";"safe"]"Make sure nothing will be automatically updated or rewritten. Useful \
for calling from completion scripts, for example. Will fail whenever \
such an operation is needed ; also avoids waiting for locks, skips \
interactive questions and overrides the $(b,\\$OPAMDEBUG) variable. \
This is equivalent to set environment variable $(b,\\$OPAMSAFE)."inletjson_flag=mk_opt~clicli_original~section["json"]"FILENAME""Save the results of the opam run in a computer-readable file. If the \
filename contains the character `%', it will be replaced by an index \
that doesn't overwrite an existing file. Similar to setting the \
$(b,\\$OPAMJSON) variable."Arg.(somestring)Noneinletno_auto_upgrade=mk_flag~clicli_original~section["no-auto-upgrade"]"When configuring or updating a repository that is written for an \
earlier opam version (1.2), opam internally converts it to the current \
format. This disables this behaviour. Note that repositories should \
define their format version in a 'repo' file at their root, or they \
will be assumed to be in the older format. It is, in any case, \
preferable to upgrade the repositories manually using $(i,opam admin \
upgrade [--mirror URL]) when possible."inletworking_dir=mk_flag~clicli_original~section["working-dir";"w"]"Whenever updating packages that are bound to a local, \
version-controlled directory, update to the current working state of \
their source instead of the last committed state, or the ref they are \
pointing to. As source directory is copied as it is, if it isn't clean \
it may result on a opam build failure. This only affects packages \
explicitly listed on the command-line. It can also be set with \
$(b,\\$OPAMWORKINGDIR)."inletignore_pin_depends=mk_flag~clicli_original~section["ignore-pin-depends"]"Ignore extra pins required by packages that get pinned, either manually \
through $(i,opam pin) or through $(i,opam install DIR). This is \
equivalent to setting $(b,IGNOREPINDEPENDS=true)."inTerm.(constcreate_global_options$git_version$debug$debug_level$verbose$quiet$color$switch$yes$confirm_level$strict$root$external_solver$use_internal_solver$cudf_file$solver_preferences$best_effort$safe_mode$json_flag$no_auto_upgrade$working_dir$ignore_pin_depends$d_no_aspcud$cli_arg)(* lock options *)letlocked?sectioncli=mk_flag~clicli_original?section["locked"]"In commands that use opam files found from pinned sources, if a variant \
of the file with an added .$(i,locked) extension is found (e.g. \
$(b,foo.opam.locked) besides $(b,foo.opam)), that will be used instead. \
This is typically useful to offer a more specific set of dependencies \
and reproduce similar build contexts, hence the name. The $(i, lock)\
option can be used to generate such files, based on the versions \
of the dependencies currently installed on the host. This is equivalent \
to setting the $(b,\\$OPAMLOCKED) environment variable. Note that this \
option doesn't generally affect already pinned packages."letlock_suffix?sectioncli=mk_opt~cli(cli_fromcli2_1)?section["lock-suffix"]"SUFFIX""Set locked files suffix to $(i,SUFFIX)."Arg.(string)("locked")(* Checksums options *)letno_checksums?sectionclifrom_cli=mk_flag~clifrom_cli?section["no-checksums"]"Do not verify the checksum of downloaded archives.\
This is equivalent to setting $(b,\\$OPAMNOCHECKSUMS) to \"true\"."letrequire_checksums?sectionclifrom_cli=mk_flag~clifrom_cli?section["require-checksums"]"Reject the installation of packages that don't provide a checksum for\
the upstream archives. This is equivalent to setting \
$(b,\\$OPAMREQUIRECHECKSUMS) to \"true\"."(* Options common to all build commands *)letbuild_option_section="PACKAGE BUILD OPTIONS"letman_build_option_section=[`Sbuild_option_section;]letbuild_optionscli=letsection=build_option_sectioninletkeep_build_dir=mk_flag~clicli_original~section["b";"keep-build-dir"]"Keep the build directories after compiling packages. \
This is equivalent to setting $(b,\\$OPAMKEEPBUILDDIR) to \"true\"."inletreuse_build_dir=mk_flag~clicli_original~section["reuse-build-dir"]"Reuse existing build directories (kept by using $(b,--keep-build-dir)), \
instead of compiling from a fresh clone of the source. This can be \
faster, but also lead to failures if the build systems of the packages \
don't handle upgrades of dependencies well. This is equivalent to \
setting $(b,\\$OPAMREUSEBUILDDIR) to \"true\"."inletinplace_build=mk_flag~clicli_original~section["inplace-build"]"When compiling a package which has its source bound to a local \
directory, process the build and install actions directly in that \
directory, rather than in a clean copy handled by opam. This only \
affects packages that are explicitly listed on the command-line. \
This is equivalent to setting $(b,\\$OPAMINPLACEBUILD) to \"true\"."inletno_checksums=no_checksums~sectionclicli_originalinletreq_checksums=require_checksums~sectionclicli_originalinletbuild_test=mk_flag_replaced~cli~section[cli_betweencli2_0cli2_1~replaced:"--with-test",["build-test"];cli_original,["t";"with-test"];]"Build and $(b,run) the package unit-tests. This only affects packages \
listed on the command-line. This is equivalent to setting \
$(b,\\$OPAMWITHTEST) (or the deprecated $(b,\\$OPAMBUILDTEST)) to \
\"true\"."inletbuild_doc=mk_flag_replaced~cli~section[cli_betweencli2_0cli2_1~replaced:"--with-doc",["build-doc"];cli_original,["d";"with-doc"];]"Build the package documentation. This only affects packages listed on \
the command-line. This is equivalent to setting $(b,\\$OPAMWITHDOC) \
(or the deprecated $(b,\\$OPAMBUILDDOC)) to \"true\"."inletdev_setup=mk_flag~cli(cli_fromcli2_2)["with-dev-setup"]~section"Include development tools only dependencies."inletmake=mk_opt~cli(cli_betweencli2_0cli2_1~replaced:"opam config set[-global] make MAKE")~section["m";"make"]"MAKE""Use $(docv) as the default 'make' command. Has no effect if the \
$(i,make) variable is defined."Arg.(somestring)Noneinletshow=mk_flag~clicli_original~section["show-actions"]"Call the solver and display the actions. Don't perform any changes. \
This is equivalent to setting $(b,\\$OPAMSHOW)."inletdryrun=mk_flag~clicli_original~section["dry-run"]"Simulate the command, but don't actually perform any changes. This also \
can be set with environment variable $(b,\\$OPAMDEBUG)."inletskip_update=mk_flag~clicli_original~section["skip-updates"]"When running an install, upgrade or reinstall on source-pinned \
packages, they are normally updated from their origin first. This flag \
disables that behaviour and will keep them to their version in cache. \
This is equivalent to setting $(b,\\$OPAMSKIPUPDATE)."inletfake=mk_flag~clicli_original~section["fake"]"This option registers the actions into the opam database, without \
actually performing them. \
WARNING: This option is dangerous and likely to break your opam \
environment. You probably want $(b,--dry-run). You've been $(i,warned)."inletignore_constraints_on=mk_opt~clicli_original~section["ignore-constraints-on"]"PACKAGES""Forces opam to ignore version constraints on all dependencies to the \
listed packages. This can be used to test compatibility, but expect \
builds to break when using this. Note that availability of the packages \
as well as version constraints on optional dependencies and conflicts \
are unaffected. This is equivalent to setting $(b,\\$OPAMIGNORECONSTRAINTS)."Arg.(some(listpackage_name))None~vopt:(Some[])inletunlock_base=mk_flag_replaced~cli~section[cli_betweencli2_0cli2_1~replaced:"--update-invariant",["unlock-base"];cli_fromcli2_1,["update-invariant"]]"Allow changes to the packages set as switch base (typically, the main \
compiler). Use with caution. This is equivalent to setting the \
$(b,\\$OPAMUNLOCKBASE) environment variable"inletlocked=lockedcli~sectioninletlock_suffix=lock_suffixcli~sectioninletassume_depexts=mk_flag~cli(cli_fromcli2_1)~section["assume-depexts"]"Skip the installation step for any missing system packages, and attempt \
to proceed with compilation of the opam packages anyway. If the \
installation is successful, opam won't prompt again about these system \
packages. Only meaningful if external dependency handling is enabled."inletno_depexts=mk_flag~cli(cli_fromcli2_1)~section["no-depexts"]"Temporarily disables handling of external dependencies. This can be \
used if a package is not available on your system package manager, but \
you installed the required dependency by hand. Implies \
$(b,--assume-depexts), and stores the exceptions upon success as well."inletverbose_on=mk_opt~cli(cli_fromcli2_3)~section["verbose-on"]"PACKAGES""Be more verbose on specific packages.\
This is equivalent to setting $(b,\\$OPAMVERBOSE)."Arg.(some(listpackage_name))NoneinTerm.(constcreate_build_options$keep_build_dir$reuse_build_dir$inplace_build$make$no_checksums$req_checksums$build_test$build_doc$dev_setup$show$dryrun$skip_update$fake$jobs_flag~sectionclicli_original$ignore_constraints_on$unlock_base$locked$lock_suffix$assume_depexts$no_depexts$verbose_on)(* Option common to install commands *)letassume_built?sectioncli=mk_flag~clicli_original?section["assume-built"]"For use on locally-pinned packages: assume they have already \
been correctly built, and only run their installation \
instructions, directly from their source directory. This \
skips the build instructions and can be useful to install \
packages that are being worked on. Implies $(i,--inplace-build). \
No locally-pinned packages will be skipped."(* Options common to all path based/related commands, e.g. (un)pin, upgrade,
remove, (re)install. *)letrecurse?sectioncli=mk_flag~cli(cli_fromcli2_2)?section["recursive"]"Allow recursive lookups of $(b,*.opam) files. Cf. $(i,--subpath) also."letsubpath?sectioncli=mk_opt~cli(cli_fromcli2_2)?section["subpath"]"PATH""$(b,*.opam) files are retrieved from the given sub directory instead of \
top directory. Sources are then taken from the targeted sub directory, \
internally only this subdirectory is copied/fetched. It can be combined \
with $(i,--recursive) to have a recursive lookup on the subpath."Arg.(somesubpath_conv)Noneletpackage_selection_section="PACKAGE SELECTION OPTIONS"letorder_sensible_selector_section="ORDER-SENSIBLE SELECTORS"letpost?(section=package_selection_section)cli=mk_flag~clicli_original["post"]~section"Include dependencies tagged as $(i,post)."letdev?(section=package_selection_section)cli=mk_flag~clicli_original["dev"]~section"Include development packages in dependencies."letdoc_flag?(section=package_selection_section)cli=mk_flag~clicli_original["doc";"with-doc"]~section"Include doc-only dependencies."lettest?(section=package_selection_section)cli=mk_flag~clicli_original["t";"test";"with-test"]~section"Include test-only dependencies."letdev_setup?(section=package_selection_section)cli=mk_flag~cli(cli_fromcli2_2)["with-dev-setup"]~section"Include developer only dependencies."letpackage_selectioncli=letsection=package_selection_sectioninletdepends_on=mk_opt_all~clicli_original["depends-on"]"PACKAGES"~section"List only packages that depend on one of (comma-separated) $(b,PACKAGES)."Arg.(listatom)inletrequired_by=mk_opt_all~clicli_original["required-by"]"PACKAGES"~section"List only the dependencies of (comma-separated) $(b,PACKAGES)."Arg.(listatom)inletconflicts_with=mk_opt_all~clicli_original["conflicts-with"]"PACKAGES"~section"List packages that have declared conflicts with at least one of the \
given list. This includes conflicts defined from the packages in the \
list, from the other package, or by a common $(b,conflict-class:) \
field."Arg.(listpackage_with_version)inletcoinstallable_with=mk_opt_all~clicli_original["coinstallable-with"]"PACKAGES"~section"Only list packages that are compatible with all of $(b,PACKAGES)."Arg.(listpackage_with_version)inletresolve=mk_opt_all~clicli_original["resolve"]"PACKAGES"~section"Restrict to a solution to install (comma-separated) $(docv), $(i,i.e.) \
a consistent set of packages including those. This is subtly different \
from `--required-by --recursive`, which is more predictable and can't \
fail, but lists all dependencies independently without ensuring \
consistency. \
Without `--installed`, the answer is self-contained and independent of \
the current installation. With `--installed', it's computed from the \
set of currently installed packages. \
`--no-switch` further makes the solution independent from the \
currently pinned packages, architecture, and compiler version. \
The combination with `--depopts' is not supported."Arg.(listatom)inletrecursive=mk_flag~clicli_original["recursive"]~section"With `--depends-on' and `--required-by', display all transitive \
dependencies rather than just direct dependencies."inletdepopts=mk_flag~clicli_original["depopts"]~section"Include optional dependencies in dependency requests."inletnobuild=mk_flag~clicli_original["nobuild"]~section"Exclude build dependencies (they are included by default)."inletfield_match=mk_opt_all~clicli_original["field-match"]"FIELD:PATTERN"~section"Filter packages with a match for $(i,PATTERN) on the given $(i,FIELD)"Arg.(pair~sep:':'stringstring)inlethas_flag=mk_opt_all~clicli_original["has-flag"]"FLAG"~section("Only include packages which have the given flag set. \
Package flags are one of: "^(OpamStd.List.concat_map" "(Printf.sprintf"$(b,%s)"@*string_of_pkg_flag)all_package_flags))((funs->matchpkg_flag_of_stringswith|Pkgflag_Unknowns->`Error("Invalid package flag "^s^", must be one of "^OpamStd.List.concat_map" "string_of_pkg_flagall_package_flags)|f->`Okf),funfmtflag->Format.pp_print_stringfmt(string_of_pkg_flagflag))inlethas_tag=mk_opt_all~clicli_original["has-tag"]"TAG"~section"Only includes packages which have the given tag set"Arg.stringinletfilterdepends_onrequired_byconflicts_withcoinstallable_withresolverecursivedepoptsnobuildpostdevdoc_flagtestdev_setupfield_matchhas_flaghas_tag=letdependency_toggles={OpamListCommand.recursive;depopts;build=notnobuild;post;test;dev_setup;doc=doc_flag;dev}inList.map(funflag->OpamListCommand.Flagflag)has_flag@List.map(funtag->OpamListCommand.Tagtag)has_tag@List.map(fun(field,patt)->OpamListCommand.Pattern({OpamListCommand.default_pattern_selectorwithOpamListCommand.fields=[field]},patt))field_match@List.map(fundeps->OpamListCommand.Depends_on(dependency_toggles,deps))depends_on@List.map(funrdeps->OpamListCommand.Required_by(dependency_toggles,rdeps))required_by@List.map(funpkgs->OpamListCommand.Conflicts_withpkgs)conflicts_with@List.map(fundeps->OpamListCommand.Solution(dependency_toggles,deps))resolve@List.map(funpkgs->OpamListCommand.Coinstallable_with(dependency_toggles,pkgs))coinstallable_withinTerm.(constfilter$depends_on$required_by$conflicts_with$coinstallable_with$resolve$recursive$depopts$nobuild$postcli$devcli$doc_flagcli$testcli$dev_setupcli$field_match$has_flag$has_tag)letpackage_listing_section="OUTPUT FORMAT OPTIONS"letpackage_listingcli=letsection=package_listing_sectioninletall_versions=mk_flag~clicli_original["all-versions";"V"]~section"Normally, when multiple versions of a package match, only one is shown \
in the output (the installed one, the pinned-to one, or, failing that, \
the highest one available or the highest one). This flag disables this \
behaviour and shows all matching versions. This also changes the \
default display format to include package versions instead of just \
package names (including when --short is set). This is automatically \
turned on when a single non-pattern package name is provided on the \
command-line."inletprint_short=mk_flag~clicli_original["short";"s"]~section"Don't print a header, and sets the default columns to $(b,name) only. \
If you need package versions included, use $(b,--columns=package) \
instead"inletsort=mk_flag~clicli_original["sort";"S"]~section"Sort the packages in dependency order (i.e. an order in which they \
could be individually installed.)"inletcolumns=mk_opt~clicli_original["columns"]"COLUMNS"~section(Printf.sprintf"Select the columns to display among: %s.\n\
The default is $(b,name) when $(i,--short) is present \
and %s otherwise."(OpamStd.List.concat_map", "(fun(_,f)->Printf.sprintf"$(b,%s)"f)OpamListCommand.raw_field_names)(OpamStd.List.concat_map", "(funf->Printf.sprintf"$(b,%s)"(OpamListCommand.string_of_fieldf))OpamListCommand.default_list_format))Arg.(some&opamlist_columns)Noneinletnormalise=mk_flag~clicli_original["normalise"]~section"Print the values of opam fields normalised"inletwrap=mk_flag~clicli_original["wrap"]~section"Wrap long lines, the default being to truncate when displaying on a \
terminal, or to keep as is otherwise"inletseparator=mk_opt~clicli_original["separator"]"STRING"~section"Set the column-separator string"Arg.string" "inletformatall_versionsshortsortcolumnsnormalisewrapseparator=fun~force_all_versions->letall_versions=force_all_versions||all_versionsinletcolumns=matchcolumnswith|Somec->c|None->letcols=ifshortthen[OpamListCommand.Name]elseOpamListCommand.default_list_formatinifall_versionsthenList.map(function|OpamListCommand.Name->OpamListCommand.Package|c->c)colselsecolsin{OpamListCommand.short;header=notshort;columns;all_versions;wrap=ifwrapthenSome(`Wrap"\\ ")elseSome`Truncate;separator;value_printer=ifnormalisethen`Normalisedelse`Normal;order=ifsortthen`Dependencyelse`Standard;}inTerm.(constformat$all_versions$print_short$sort$columns$normalise$wrap$separator)