blob: ad997408632bcb493fd42affe906b61a169aa6fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module Opts = struct
open Arg
type lasttype = NAME | SYMB
let ltype = ref NAME
let gendb = ref ""
let maxmatch = ref 3
let match_name : string list ref = ref []
let match_symb : string list ref = ref []
let dbfile = ref "elements.sqlite3"
let add_name s =
match_name := s::!match_name;
ltype := NAME
let add_symb s =
match_symb := s::!match_symb;
ltype := SYMB
let add_def s = match !ltype with
| NAME -> add_name s
| SYMB -> add_symb s
let msg = "Periodic table search\n\
elements -gendb file [-dbfile outfile]\n\
elements [-maxmatch n] [-dbfile search] [-name ...] [-symb ...]\n\
"
let spec = [
"-gendb", Set_string gendb, "Generate DB file";
"-maxmatch", Set_int maxmatch, "Limit the amount of matches (def. 3)";
"-dbfile", Set_string dbfile, "Set the DB filename";
"-name", String add_name, "Search by name (default)";
"-symb", String add_symb, "Search by symbol"
]
let exec() = parse spec add_def msg
end
let () = Opts.exec()
|