@@ -33,6 +33,7 @@ let input_file list file =
33
33
close_in ic
34
34
35
35
let () =
36
+ let target_access = ref None in
36
37
let access = ref None in
37
38
let list = ref [] in
38
39
let bname = ref " " in
@@ -41,10 +42,23 @@ let () =
41
42
let access_opt opt doc x =
42
43
(opt, Arg. Unit (fun () -> set_access x), " Set access flag to " ^ doc ^ " ." )
43
44
in
45
+ let access_of_string s = match s with
46
+ | "public" -> Some Def. Public
47
+ | "private" -> Some Def. Private
48
+ | "default" -> Some Def. IfTitles
49
+ | _ -> None
50
+ in
51
+ let set_target_access_of_string s =
52
+ assert (! target_access = None );
53
+ let access_opt = access_of_string s in
54
+ assert (Option. is_some access_opt);
55
+ target_access := access_opt
56
+ in
44
57
let speclist =
45
58
[ access_opt " --private" " PRIVATE" Def. Private
46
59
; access_opt " --public" " PUBLIC" Def. Public
47
60
; access_opt " --default" " IFTITLE" Def. IfTitles
61
+ ; " --target" , Arg. String (fun s -> set_target_access_of_string s), " [public|default|private] Proccess only persons with given access"
48
62
; " --everybody" , Arg. Set everybody, " process the wole base."
49
63
; " --key" , Arg. String (fun s -> list := s :: ! list ), " <KEY>"
50
64
; " --keys" , Arg. String (fun s -> input_file list s), " <FILE> file containing one key per line."
@@ -54,12 +68,17 @@ let () =
54
68
let anonfun i = bname := i in
55
69
let usage = " Usage: " ^ Sys. argv.(0 ) ^ " [-everybody] [-ind key] [-list-ind file] base" in
56
70
Arg. parse speclist anonfun usage ;
57
- match ! bname, ! access, ! everybody, ! list with
58
- | ("" , _ , _ , _ ) | (_ , None , _ , _ ) | (_ , _ , false , [] ) ->
71
+ match ! bname, ! access, ! everybody, ! target_access, ! list with
72
+ | ("" , _ , _ , _ , _ ) | (_ , None , _ , _ , _ ) | (_ , _ , false , None , [] ) ->
59
73
Arg. usage speclist usage ;
60
74
exit 2 ;
61
- | (bname , Some access , everybody , list ) ->
75
+ | (bname , Some access , everybody , target_access , list ) ->
62
76
Secure. set_base_dir (Filename. dirname bname);
63
77
Lock. control_retry (Files. lock_file bname) ~onerror: Lock. print_error_and_exit @@ fun () ->
64
- if everybody then Gwaccess_util. access_everybody access bname
78
+ if Option. is_some target_access then
79
+ Gwaccess_util. change_only_old_access
80
+ ~old_access: (Option. get target_access)
81
+ ~new_access: access
82
+ bname
83
+ else if everybody then Gwaccess_util. access_everybody access bname
65
84
else access_some access bname list
0 commit comments