package opam_bin_lib

  1. Overview
  2. Docs

Source file main.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2020 OCamlPro & Origin Labs                               *)
(*                                                                        *)
(*  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.                   *)
(*                                                                        *)
(**************************************************************************)

let commands = [
  CommandConfig.cmd ;
  CommandInstall.cmd ;
  CommandUninstall.cmd ;
  CommandPush.cmd ;
  CommandPull.cmd ;
  CommandClean.cmd ;
  CommandList.cmd ;
  CommandInfo.cmd ;
  CommandSearch.cmd ;

  CommandPreSession.cmd ;
  CommandPreBuild.cmd ;
  CommandWrapBuild.cmd ;
  CommandPreInstall.cmd ;
  CommandWrapInstall.cmd ;
  CommandPostInstall.cmd ;
  CommandPostSession.cmd ;
  CommandPreRemove.cmd ;
  CommandShare.cmd ;
]


let main () =
  (match Sys.getenv "OPAM_BIN_BACK_TRACE" with
   | exception _ -> ()
   | _ -> Printexc.record_backtrace true);
  match Sys.argv with
  | [| _ ; "--version" |] ->
    Printf.printf "%s\n%!" Version.version
  | [| _ ; "--about" |] ->
    Printf.printf "%s\n%!" Globals.about
  | _ ->
(*    Misc.global_log "args: %s"
      (String.concat " " (Array.to_list Sys.argv)); *)
    try
      Ezcmd.main_with_subcommands
        ~name:Globals.command
        ~version:Version.version
        ~doc:"Create binary archives of OPAM source packages"
        ~man:[]
        commands
    with
      exn ->
      let bt = Printexc.get_backtrace () in
      let error = Printexc.to_string exn in
      Printf.eprintf "fatal exception %s\n%s\n%!" error bt ;
      Misc.global_log ~nvo:None "fatal exception %s\n%s" error bt;
      exit 2