70c2b4dbea74155285a67220f7e8800e5f77f364
[tatoo.git] / src / options.ml
1 open Arg
2
3 let count = ref false
4 let input_file : string option ref = ref None
5 let output_file : string option ref = ref None
6 let query = ref ""
7 let stats = ref false
8
9 let set_string_option r s = r := Some s
10
11 let specs = align [
12   "-c", Set count, " write the number of results only";
13   "--count", Set count, " ";
14   "-s", Set stats, " display timing and various statistics";
15   "--stats", Set stats, " ";
16   "-d", String (set_string_option input_file), " specify the input document file [default stdin]";
17   "--doc", String (set_string_option input_file), " ";
18   "-o", String (set_string_option output_file), " specify the output file [default stdout]";
19   "--out", String (set_string_option output_file), " ";
20 ]
21
22 let usage_msg = Printf.sprintf "usage: %s [options] query" Sys.argv.(0)
23
24 let usage () = usage specs usage_msg
25
26 let parse () =
27   parse specs (fun q -> query := q) usage_msg
28