Skip to content
Newer
Older
100644 370 lines (343 sloc) 12.1 KB
bad6023 @samoht Add GPL headers
samoht authored
1 (***********************************************************************)
2 (* *)
3 (* Copyright 2012 OCamlPro *)
4 (* Copyright 2012 INRIA *)
5 (* *)
6 (* All rights reserved. This file is distributed under the terms of *)
7 (* the GNU Public License version 3.0. *)
8 (* *)
9 (* TypeRex is distributed in the hope that it will be useful, *)
10 (* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
11 (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
12 (* GNU General Public License for more details. *)
13 (* *)
14 (***********************************************************************)
15
970ea15 @samoht [install] 'opam install' consider all the packages given as argument …
samoht authored
16 open Utils
18982ee @samoht OPAM compiles.
samoht authored
17 open Types
2c9a85c @samoht More file spliting.
samoht authored
18 open Path
19 open Solver
20 open Client
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
21 open SubCommand
3d75c58 @samoht More clean-ups.
samoht authored
22
23 let version () =
24 Printf.printf "\
25 %s version %s
26
27 Copyright (C) 2012 OCamlPro - INRIA
28
29 This is free software; see the source for copying conditions. There is NO
30 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
d536940 @samoht Properly display the version message when using --version
samoht authored
31 Sys.argv.(0) Globals.version;
32 exit 0
3d75c58 @samoht More clean-ups.
samoht authored
33
34 let ano_args = ref []
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
35 let anon s =
36 ano_args := s :: !ano_args
37
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
38 exception Bad of string * string
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
39
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
40 let bad_argument cmd fmt =
41 Printf.kprintf (fun msg -> raise (Bad (cmd, msg))) fmt
42
43 let noanon cmd s =
44 raise (Bad (cmd, s ^ " is not expected"))
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
45
f8dc221 @samoht Add --root to ocp-get and ocp-get-server to change the default root p…
samoht authored
46 let () = Globals.root_path := Globals.default_opam_path
47
7929791 @samoht opam switch is verbose by default
samoht authored
48 (* Useful for switch, who overwrite the default verbose flag *)
49 let quiet = ref false
50
8afaa59 @samoht Cool new features
samoht authored
51 let global_args = [
b9c13df @tuong [solver heuristic] Add an option to force the version of every packag…
tuong authored
52 "--debug" , Arg.Set Globals.debug, " Print more debug messages";
53 "--verbose" , Arg.Set Globals.verbose, " Display the stdout/stderr of subprocesses";
54 "--quiet" , Arg.Clear quiet, " Not display the stdout/stderr of subprocesses";
55 "--version" , Arg.Unit version, " Display version information";
56 "--yes" , Arg.Set Globals.yes, " Answer yes to all questions";
57 "--root" , Arg.Set_string Globals.root_path,
58 (Printf.sprintf " Change root path (default is %s)" Globals.default_opam_path);
3d75c58 @samoht More clean-ups.
samoht authored
59 ]
60
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
61 let parse_args fn () =
62 fn (List.rev !ano_args)
63
18982ee @samoht OPAM compiles.
samoht authored
64 (* opam init [-kind $kind] $repo $adress *)
d38f416 @tuong [OCaml version] replication works
tuong authored
65 let init =
66 let kind = ref Globals.default_repository_kind in
a4d01ec @tuong [opam init -comp] fix the failure to start when there is no OCaml (ex…
tuong authored
67 let alias = ref None in
68 let comp = ref None in
e760c1c @samoht [init] the user can configure the number of cores to use on init
samoht authored
69 let cores = ref Globals.default_cores in
d38f416 @tuong [OCaml version] replication works
tuong authored
70 {
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
71 name = "init";
72 usage = "";
73 synopsis = "Initial setup";
74 help = "Create the initial config files";
e8a06af @samoht Start to add the support for git package repository
samoht authored
75 specs = [
a4d01ec @tuong [opam init -comp] fix the failure to start when there is no OCaml (ex…
tuong authored
76 ("-comp" , Arg.String (fun s -> comp := Some (OCaml_V.of_string s)), " Which compiler version to use");
77 ("-alias", Arg.String (fun s -> alias := Some (Alias.of_string s)), " Set the compiler alias name");
e760c1c @samoht [init] the user can configure the number of cores to use on init
samoht authored
78 ("-cores", Arg.Set_int cores , " Set the nomber of cores");
640a3ba @samoht Add an option to not install the base packages on init
samoht authored
79 ("-kind" , Arg.Set_string kind , " Set the repository kind");
80 ("-no-base-packages", Arg.Clear Globals.base_packages, " Do not install the base packages");
e8a06af @samoht Start to add the support for git package repository
samoht authored
81 ];
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
82 anon;
83 main =
84 parse_args (function
d72de1d @samoht More cleanups
samoht authored
85 | [] ->
a4d01ec @tuong [opam init -comp] fix the failure to start when there is no OCaml (ex…
tuong authored
86 Client.init Repository.default !alias !comp !cores
d72de1d @samoht More cleanups
samoht authored
87 | [name; address] ->
0492aae @samoht [switch] More improvments
samoht authored
88 let repo = Repository.create ~name ~address ~kind:!kind in
a4d01ec @tuong [opam init -comp] fix the failure to start when there is no OCaml (ex…
tuong authored
89 Client.init repo !alias !comp !cores
18982ee @samoht OPAM compiles.
samoht authored
90 | _ -> bad_argument "init" "Need a repository name and address")
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
91 }
92
ac99a15 @samoht More WIP ...
samoht authored
93 (* opam list *)
0c38056 @tuong [opam list -short] can be used to list only the package that are avai…
tuong authored
94 let list =
95 let short = ref false in
96 {
0acb675 @samoht 'ocp-get list' returns the list of available packages
samoht authored
97 name = "list";
98 usage = "";
99 synopsis = "Display information about all available packages";
100 help = "";
0c38056 @tuong [opam list -short] can be used to list only the package that are avai…
tuong authored
101 specs = [
102 ("-short", Arg.Set short, " Minimize the output by displaying only package name (installed and not installed)");
103 ];
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
104 anon = noanon "list";
0c38056 @tuong [opam list -short] can be used to list only the package that are avai…
tuong authored
105 main = parse_args (fun _ -> Client.list !short);
0acb675 @samoht 'ocp-get list' returns the list of available packages
samoht authored
106 }
107
ac99a15 @samoht More WIP ...
samoht authored
108 (* opam info [PACKAGE] *)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
109 let info = {
110 name = "info";
0acb675 @samoht 'ocp-get list' returns the list of available packages
samoht authored
111 usage = "[package]+";
112 synopsis = "Display information about specific packages";
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
113 help = "";
114 specs = [];
115 anon;
116 main =
117 parse_args (function
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
118 | [] -> bad_argument "info" "Missing package argument"
18982ee @samoht OPAM compiles.
samoht authored
119 | l -> List.iter (fun name -> Client.info (N.of_string name)) l)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
120 }
121
18982ee @samoht OPAM compiles.
samoht authored
122 (* opam config [-r [-I|-bytelink|-asmlink] PACKAGE+ *)
8d4f10e @samoht Add an option to display the current env variables
samoht authored
123 let config =
124 let has_cmd = ref false in
125 let is_rec = ref false in
126 let is_link = ref false in
127 let is_byte = ref false in
128 let bytecomp () = has_cmd := true; is_byte := true ; is_link := false in
129 let bytelink () = has_cmd := true; is_byte := true ; is_link := true in
130 let asmcomp () = has_cmd := true; is_byte := false; is_link := false in
131 let asmlink () = has_cmd := true; is_byte := false; is_link := true in
132 let command = ref None in
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
133 let set cmd () =
134 has_cmd := true;
8d4f10e @samoht Add an option to display the current env variables
samoht authored
135 command := Some cmd in
18982ee @samoht OPAM compiles.
samoht authored
136 let specs = [
943f71b @samoht Fix typos in help messages
samoht authored
137 ("-r" , Arg.Set is_rec , " Recursive search");
138 ("-I" , Arg.Unit (set `I) , " Display include options");
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
139 ("-bytecomp" , Arg.Unit bytecomp , " Display bytecode compile options");
943f71b @samoht Fix typos in help messages
samoht authored
140 ("-asmcomp" , Arg.Unit asmcomp , " Display native compile options");
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
141 ("-bytelink" , Arg.Unit bytelink , " Display bytecode link options");
142 ("-asmlink" , Arg.Unit asmlink , " Display native link options");
143 ("-list-vars", Arg.Unit (set `List) , " Display the contents of all available variables");
144 ("-var" , Arg.Unit (set `Var) , " Display the content of a variable");
145 ("-subst" , Arg.Unit (set `Subst), " Substitute variables in files");
8d4f10e @samoht Add an option to display the current env variables
samoht authored
146 ("-env" , Arg.Unit (set `Env) , " Display the compiler environment variables");
147 ] in
18982ee @samoht OPAM compiles.
samoht authored
148 let mk options =
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
149 if not !has_cmd then
7bf2be6 @samoht [tests] P1, P2 and P3 compiles again.
samoht authored
150 bad_argument "config"
151 "Wrong options (has_cmd=%b is_rec=%b,is_link=%b,is_byte=%b)"
152 !has_cmd !is_rec !is_link !is_byte
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
153 else
154 Compil {
155 is_rec = !is_rec;
156 is_link = !is_link;
157 is_byte = !is_byte;
7bf2be6 @samoht [tests] P1, P2 and P3 compiles again.
samoht authored
158 options = List.map Full_section.of_string options;
8d4f10e @samoht Add an option to display the current env variables
samoht authored
159 } in
160 {
18982ee @samoht OPAM compiles.
samoht authored
161 name = "config";
162 usage = "[...]+";
163 synopsis = "Display configuration options for packages";
164 help = "";
165 specs;
166 anon;
167 main = function () ->
168 let names = List.rev !ano_args in
169 let config = match !command with
8d4f10e @samoht Add an option to display the current env variables
samoht authored
170 | Some `Env -> Env
7bf2be6 @samoht [tests] P1, P2 and P3 compiles again.
samoht authored
171 | Some `I -> Includes (!is_rec, List.map N.of_string names)
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
172 | Some `List -> List_vars
a97b6ff @samoht [config] opam config -var VAR works
samoht authored
173 | Some `Var when List.length names = 1
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
174 -> Variable (Full_variable.of_string (List.hd names))
175 | Some `Var ->
8c20b57 @samoht [config] opam config -subst <file>+ work
samoht authored
176 bad_argument "config" "-var takes exactly one parameter"
bd3a033 @samoht [repo-server] read/write OPAM server can now be used as a repository …
samoht authored
177 | Some `Subst -> Subst (List.map Basename.of_string names)
b94eecb @samoht [config] clean-ups + opam config -I <package> works
samoht authored
178 | None -> mk names in
18982ee @samoht OPAM compiles.
samoht authored
179 Client.config config
180 }
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
181
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
182 (* opam install PACKAGE *)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
183 let install = {
184 name = "install";
185 usage = "[package]+";
5ef1a22 @tuong [opam remove] takes a list of packages as before, but now the solving…
tuong authored
186 synopsis = "Install a list of package";
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
187 help = "";
188 specs = [];
189 anon;
970ea15 @samoht [install] 'opam install' consider all the packages given as argument …
samoht authored
190 main = parse_args (fun names ->
191 let names = List.map N.of_string names in
192 Client.install (N.Set.of_list names)
193 )
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
194 }
195
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
196 (* opam update *)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
197 let update = {
198 name = "update";
199 usage = "[package]+";
200 synopsis = "Update the installed package to latest version";
201 help = "";
202 specs = [];
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
203 anon = noanon "update";
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
204 main = Client.update;
205 }
206
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
207 (* opam upgrade *)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
208 let upgrade = {
209 name = "upgrade";
210 usage = "";
211 synopsis = "Upgrade the list of available package";
212 help = "";
213 specs = [];
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
214 anon = noanon "upgrade";
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
215 main = Client.upgrade;
216 }
217
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
218 (* opam upload PACKAGE *)
d38f416 @tuong [OCaml version] replication works
tuong authored
219 let upload =
220 let opam = ref "" in
221 let descr = ref "" in
222 let archive = ref "" in
223 let repo = ref "" in
224 {
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
225 name = "upload";
226 usage = "";
227 synopsis = "Upload a package to the server";
228 help = "";
18982ee @samoht OPAM compiles.
samoht authored
229 specs = [
230 ("-opam" , Arg.Set_string opam , " specify the OPAM file to upload");
231 ("-descr" , Arg.Set_string descr , " specify the description file to upload");
232 ("-archive", Arg.Set_string archive, " specify the archive file to upload");
233 ("-repo" , Arg.Set_string repo , " (optional) specify the repository to upload")
234 ];
235 anon = noanon "upload";
236 main = (function () ->
237 if !opam = "" then
238 bad_argument "upload" "missing OPAM file";
239 if !descr = "" then
240 bad_argument "upload" "missing description file";
241 if !archive = "" then
242 bad_argument "upload" "missing archive file";
243 let opam = Filename.of_string !opam in
244 let descr = Filename.of_string !descr in
245 let archive = Filename.of_string !archive in
39771d6 @samoht Init / Update / Upload works
samoht authored
246 let repo = if !repo = "" then None else Some !repo in
18982ee @samoht OPAM compiles.
samoht authored
247 Client.upload { opam; descr; archive } repo)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
248 }
249
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
250 (* opam remove PACKAGE *)
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
251 let remove = {
252 name = "remove";
5ef1a22 @tuong [opam remove] takes a list of packages as before, but now the solving…
tuong authored
253 usage = "[package]+";
254 synopsis = "Remove a list of package";
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
255 help = "";
256 specs = [];
257 anon;
5ef1a22 @tuong [opam remove] takes a list of packages as before, but now the solving…
tuong authored
258 main = parse_args (fun names ->
259 let names = List.map N.of_string names in
260 Client.remove (N.Set.of_list names)
261 )
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
262 }
263
f6f4b18 @tuong fix "opam list" (tests was wrong during the 'upgrade' rule)
tuong authored
264 (* opam remote [-list|-add <url>|-rm <url>] *)
d38f416 @tuong [OCaml version] replication works
tuong authored
265 let remote =
266 let kind = ref Globals.default_repository_kind in
267 let command : [`add|`list|`rm] option ref = ref None in
268 let set c () = command := Some c in
269 {
2ef3bd8 @samoht New command: 'git remote' to manage remote indexes
samoht authored
270 name = "remote";
d1b6fb7 @samoht [remote] opam remote [-list|-add r|-rm n] works
samoht authored
271 usage = "[-list|add <name> <address>|rm <name>]";
2ef3bd8 @samoht New command: 'git remote' to manage remote indexes
samoht authored
272 synopsis = "Manage remote servers";
273 help = "";
05da563 @samoht Fix removing of remote git indexes
samoht authored
274 specs = [
266147b @samoht API simplification
samoht authored
275 ("-list" , Arg.Unit (set `list), " List the repositories");
276 ("-add" , Arg.Unit (set `add) , " Add a new repository");
277 ("-rm" , Arg.Unit (set `rm) , " Remove a remote repository");
0ebf54c @samoht Only globals args starts by --, so rename --kind to -kind
samoht authored
278 ("-kind" , Arg.Set_string kind , " (optional) Specify the repository kind");
05da563 @samoht Fix removing of remote git indexes
samoht authored
279 ];
2ef3bd8 @samoht New command: 'git remote' to manage remote indexes
samoht authored
280 anon;
d1b6fb7 @samoht [remote] opam remote [-list|-add r|-rm n] works
samoht authored
281 main = parse_args (fun args ->
282 match !command, args with
283 | Some `list, [] -> Client.remote List
284 | Some `rm, [ name ] -> Client.remote (Rm name)
285 | Some `add , [ name; address ] ->
286 Client.remote (Add (Repository.create ~name ~kind:!kind ~address))
287 | None, _ -> bad_argument "remote" "Command missing [-list|-add|-rm]"
288 | _ -> bad_argument "remote" "Wrong arguments")
2ef3bd8 @samoht New command: 'git remote' to manage remote indexes
samoht authored
289 }
290
d38f416 @tuong [OCaml version] replication works
tuong authored
291 (* opam switch [-clone] OVERSION *)
7929791 @samoht opam switch is verbose by default
samoht authored
292 let switch =
093774d @samoht [switch] Store .comp files in OPAM repositories as well
samoht authored
293 let command : [`switch|`list] ref = ref `switch in
294 let clone = ref false in
56833a2 @samoht [switch] 'opam switch 3.12.1 -alias foo' works
samoht authored
295 let alias = ref "" in
093774d @samoht [switch] Store .comp files in OPAM repositories as well
samoht authored
296 let set c () = command := c in
d38f416 @tuong [OCaml version] replication works
tuong authored
297 {
8b10261 @samoht Towards a support for multiple version of OCaml
samoht authored
298 name = "switch";
299 usage = "[compiler-name]";
300 synopsis = "Switch to an other compiler version";
301 help = "";
d38f416 @tuong [OCaml version] replication works
tuong authored
302 specs = [
093774d @samoht [switch] Store .comp files in OPAM repositories as well
samoht authored
303 ("-clone" , Arg.Set clone , " Try to keep the same installed packages");
304 ("-list" , Arg.Unit (set `list) , " List the available compiler descriptions");
56833a2 @samoht [switch] 'opam switch 3.12.1 -alias foo' works
samoht authored
305 ("-alias" , Arg.Set_string alias , " Set the compiler name");
640a3ba @samoht Add an option to not install the base packages on init
samoht authored
306 ("-no-base-packages", Arg.Clear Globals.base_packages, " Do not install the base packages");
d38f416 @tuong [OCaml version] replication works
tuong authored
307 ];
8b10261 @samoht Towards a support for multiple version of OCaml
samoht authored
308 anon;
d38f416 @tuong [OCaml version] replication works
tuong authored
309 main = parse_args (fun args ->
7929791 @samoht opam switch is verbose by default
samoht authored
310 if not !quiet then Globals.verbose := true;
093774d @samoht [switch] Store .comp files in OPAM repositories as well
samoht authored
311 match !command, args with
312 | `list , [] -> Client.compiler_list ()
313 | `switch, [] -> bad_argument "switch" "Compiler name is missing"
56833a2 @samoht [switch] 'opam switch 3.12.1 -alias foo' works
samoht authored
314 | `switch, [name] ->
315 let alias = if !alias = "" then name else !alias in
0492aae @samoht [switch] More improvments
samoht authored
316 Client.switch !clone (Alias.of_string alias) (OCaml_V.of_string name)
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
317 | _ -> bad_argument "switch" "Too many compiler names")
8b10261 @samoht Towards a support for multiple version of OCaml
samoht authored
318 }
319
8ca92a9 @samoht [pin] first version of 'opam pin'
samoht authored
320 (* opam pin [-list|-add <url>|-rm <url>] *)
321 let pin =
322 let list = ref false in
323 {
324 name = "pin";
325 usage = "<package> [<version>|<url>|none]";
326 synopsis = "Pin a given package to a specific version";
327 help = "";
328 specs = [
329 ("-list" , Arg.Set list, " List the current status of pinned packages");
330 ];
331 anon;
332 main = parse_args (function
333 | [] when !list -> Client.pin_list ()
334 | [name; arg] -> Client.pin { pin_package = N.of_string name; pin_arg = pin_option_of_string arg }
335 | _ -> bad_argument "pin" "Wrong arguments")
336 }
337
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
338 let commands = [
339 init;
0acb675 @samoht 'ocp-get list' returns the list of available packages
samoht authored
340 list;
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
341 info;
342 config;
343 install;
344 update;
345 upgrade;
346 upload;
347 remove;
2ef3bd8 @samoht New command: 'git remote' to manage remote indexes
samoht authored
348 remote;
8b10261 @samoht Towards a support for multiple version of OCaml
samoht authored
349 switch;
8ca92a9 @samoht [pin] first version of 'opam pin'
samoht authored
350 pin;
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
351 ]
3d75c58 @samoht More clean-ups.
samoht authored
352
e951116 @samoht Fix ocp-get init
samoht authored
353 let () =
93aa707 @samoht Catch sysbreak
samoht authored
354 Sys.catch_break true;
f01c78c @samoht ocp-get now have a nice command line interface (with subcommands) (us…
samoht authored
355 List.iter SubCommand.register commands;
a9deaa0 @samoht Improve messages on command-line erros
samoht authored
356 try ArgExt.parse global_args
f018b18 @samoht Display the full command line on errors
samoht authored
357 with e ->
27c2549 @samoht don't use 'exit' command in the middle of the code, as it is not hand…
samoht authored
358 Globals.msg " '%s' failed\n" (String.concat " " (Array.to_list Sys.argv));
f018b18 @samoht Display the full command line on errors
samoht authored
359 match e with
360 | Bad (cmd, msg) ->
361 ArgExt.pp_print_help (ArgExt.SubCommand cmd) Format.err_formatter global_args ();
27c2549 @samoht don't use 'exit' command in the middle of the code, as it is not hand…
samoht authored
362 Globals.msg "%s\n" msg;
f787eb2 @samoht Have a non-zero exit code on error
samoht authored
363 exit 1;
f018b18 @samoht Display the full command line on errors
samoht authored
364 | Failure ("no subcommand defined" as s) ->
365 ArgExt.pp_print_help ArgExt.NoSubCommand Format.err_formatter global_args ();
27c2549 @samoht don't use 'exit' command in the middle of the code, as it is not hand…
samoht authored
366 Globals.msg "%s\n" s;
f787eb2 @samoht Have a non-zero exit code on error
samoht authored
367 exit 2
27c2549 @samoht don't use 'exit' command in the middle of the code, as it is not hand…
samoht authored
368 | Globals.Exit i -> exit i
f018b18 @samoht Display the full command line on errors
samoht authored
369 | e -> raise e
Something went wrong with that request. Please try again.