More option printing fixes.
[SXSI/xpathcomp.git] / src / options.ml
1 let index_empty_texts = ref false
2 let sample_factor = ref 64
3 let disable_text_collection = ref false
4 let tc_threshold = ref 60000
5
6 let query = ref ""
7 let input_file = ref ""
8 let output_file = ref None
9 let save_file = ref ""
10 let count_only = ref false
11 let time = ref false
12 let bottom_up = ref false
13 let no_jump = ref false
14 let verbose = ref false
15 let text_index_type = ref 0
16
17 let set_index_type = function
18   | "default" -> text_index_type := 0
19   | "swcsa" -> text_index_type := 1
20   | "rlcsa" -> text_index_type := 2
21   | s -> raise (Arg.Bad(s))
22
23 let usage_msg = Printf.sprintf "%s [options] <input.{xml|srx}> 'query' [output]" Sys.argv.(0)
24
25
26 let pos = ref 0
27 let anon_fun =
28   fun s -> match !pos with
29     | 0 -> input_file:= s;incr pos
30     | 1 -> query := s; incr pos
31     | 2 -> output_file := Some s; incr pos
32     | _ -> raise (Arg.Bad(s))
33
34 let spec = Arg.align
35   [ "-c", Arg.Set(count_only),
36     " counting only (don't materialize the result set)";
37
38     "-f", Arg.Set_int(sample_factor),
39     "<n> sample factor [default=64]";
40
41     "-i", Arg.Set(index_empty_texts),
42     " index empty texts [default=false]";
43
44     "-d", Arg.Set(disable_text_collection),
45     " disable text collection[default=false]";
46
47     "-s", Arg.Set_string(save_file),
48     "<save_file> save the intermediate representation into file.srx";
49
50     "-b", Arg.Set(bottom_up), " real bottom up run";
51
52     "-nj", Arg.Set(no_jump), " disable jumping";
53
54     "-index-type", Arg.Symbol ([ "default"; "swcsa"; "rlcsa" ],
55                                set_index_type),
56     " choose text index type";
57
58     "-v", Arg.Set(verbose), " verbose mode";
59   ]
60
61 let parse_cmdline() =
62   let _ = Arg.parse spec anon_fun usage_msg
63   in
64   if (!pos > 3 || !pos < 2)
65   then begin Arg.usage spec usage_msg; exit 1 end
66
67
68
69
70