]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/bin/roles/roles.ml
c3dce2b8d32d9087bc310a4f3bbd7c841d38a274
[helm.git] / matita / matita / contribs / lambdadelta / bin / roles / roles.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 EE = RolesEngine
13 module EG = RolesGlobal
14 module ET = RolesTypes
15 module EU = RolesUtils
16 module WE = WebEngine
17
18 let help_B = "<url>  Set this base url (default: http://helm.cs.unibo.it/lambdadelta/)"
19 let help_C = "<dir>  Set this working directory (default: current directory)"
20 let help_L = " Debug osn lexer"
21 let help_W = " Run as an LWS application"
22 let help_X = " Reset all options to defaults"
23 let help_a = " Add selected names to a role"
24 let help_m = " Add roles relating matching names"
25 let help_o = "<version>  Add top objects for this stage"
26 let help_p = " Print current status on standard output"
27 let help_r = " Load current status"
28 let help_s = "<version>  Start a stage with this version"
29 let help_t = "<pointer>  Toggle the selection of this pointed entry"
30 let help_w = " Save current status"
31 let help   = "Usage: roles [ -LWXamprw | -B <url> | -C <dir> | -os <version> | -t <pointer> | <file> ]*"
32
33 let add_tops s =
34   EE.add_tops (EU.version_of_string s)
35
36 let new_stage s =
37   EE.new_stage (EU.version_of_string s)
38
39 let toggle_entry s =
40   EE.toggle_entry (EU.pointer_of_string s)
41
42 let process s =
43   match Filename.extension s with
44   | ".txt" -> EE.read_waiting s
45   | x      -> EU.raise_error (ET.EWrongExt x)
46
47 let _main = try
48   Arg.parse [
49     "-B", Arg.String ((:=) EG.base_url), help_B;
50     "-C", Arg.String ((:=) EG.wd), help_C;
51     "-L", Arg.Set EG.debug_lexer, help_L;
52     "-W", Arg.Unit WE.init, help_W;
53     "-X", Arg.Unit EG.clear, help_X;
54     "-a", Arg.Unit EE.add_role, help_a;
55     "-m", Arg.Unit EE.add_matching, help_m;
56     "-o", Arg.String add_tops, help_o;
57     "-p", Arg.Unit EE.print_status, help_p;
58     "-r", Arg.Unit EE.read_status, help_r;
59     "-s", Arg.String new_stage, help_s;
60     "-t", Arg.String toggle_entry, help_t;
61     "-w", Arg.Unit EE.write_status, help_w;
62   ] process help
63 with ET.Error e -> Printf.eprintf "roles: %s\n%!" (EU.string_of_error e)