]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/matex/matex.ml
59460ce4a116239ce660e4f19387b9c8674b768b
[helm.git] / matita / components / binaries / matex / matex.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 module A = Arg
13 module F = Filename
14
15 module U = NUri
16 module R = Helm_registry
17 module L = Librarian
18
19 module X = Ground
20 module G = Options
21 module E = Engine
22 module O = TeXOutput
23 module K = Kernel
24
25 let help_O = "<dir> Set this output directory"
26 let help_X = " Clear configuration and options"
27 let help_p = " omit types (default: no)"
28 let help_t = " Test anticipation (default: no)"
29
30 let help   = ""
31
32 (* internal functions *******************************************************)
33
34 let init registry =
35    R.load_from registry; 
36    if !G.no_init then begin
37       K.init ();
38       G.no_init := false;
39    end
40
41 let is_registry s =
42    F.check_suffix s ".conf.xml"
43
44 let no_init () =
45    failwith "MaTeX: main: registry not initialized" 
46
47 let malformed s =
48    failwith ("MaTeX: main: malformed argument: " ^ s)
49
50 let process s =
51    if is_registry s then init s
52    else if !G.no_init then no_init ()
53    else if L.is_uri s then E.process (U.uri_of_string s)
54    else malformed s
55
56 let main =
57 try
58    A.parse [
59       "-O", A.String ((:=) G.out_dir), help_O;
60       "-X", A.Unit G.clear, help_X;
61       "-p", A.Set G.no_types, help_p;
62       "-t", A.Set G.test, help_t;
63    ] process help
64 with
65    | X.Error s -> X.log s