11open Atd.Import
22open Atdgen_emit
33
4+ let fail_deprecated_variable = " ATDGEN_FAIL_DEPRECATED_OPTIONS"
45let maybe_fail_deprecated where =
5- match Sys. getenv " ATDGEN_FAIL_DEPRECATED_OPTIONS " with
6+ match Sys. getenv fail_deprecated_variable with
67 | "true" -> Printf. ksprintf failwith " Error: option %S is forbidden." where
78 | _ | exception _ -> ()
89
@@ -167,6 +168,7 @@ let main () =
167168
168169 " -biniou" ,
169170 Arg. Unit (fun () ->
171+ maybe_fail_deprecated " -biniou" ;
170172 set_once " output type" mode Biniou ),
171173 "
172174 [deprecated in favor of -t and -b]
@@ -175,6 +177,7 @@ let main () =
175177
176178 " -json" ,
177179 Arg. Unit (fun () ->
180+ maybe_fail_deprecated " -json" ;
178181 set_once " output type" mode Json ),
179182 "
180183 [deprecated in favor of -t and -j]
@@ -184,7 +187,7 @@ let main () =
184187 " -j-std" ,
185188 Arg. Unit (fun () -> maybe_fail_deprecated " -j-std" ),
186189 "
187- This option does nothing; kept for backwards compatibility." ;
190+ [deprecated] This option does nothing; kept for backwards compatibility." ;
188191
189192 " -j-gen-modules" ,
190193 Arg. Unit (fun () ->
@@ -197,7 +200,7 @@ let main () =
197200 " -std-json" ,
198201 Arg. Unit (fun () -> maybe_fail_deprecated " -std-json" ),
199202 "
200- No-op: same as -j-std." ;
203+ [deprecated] No-op: same as -j-std." ;
201204
202205 " -j-pp" ,
203206 Arg. String (fun s -> set_once " -j-pp" j_preprocess_input s),
@@ -237,6 +240,7 @@ let main () =
237240
238241 " -validate" ,
239242 Arg. Unit (fun () ->
243+ maybe_fail_deprecated " -validate" ;
240244 set_once " output type" mode Validate ),
241245 "
242246 [deprecated in favor of -t and -v]
@@ -287,15 +291,19 @@ let main () =
287291 Print the version identifier of atdgen and exit." ;
288292 ]
289293 in
290- let msg = sprintf " \
291- Generate OCaml code offering:
294+ let msg = sprintf
295+ { | Generate OCaml code offering :
292296 * OCaml type definitions translated from ATD file (- t)
293297 * serializers and deserializers for Biniou (- b)
294298 * serializers and deserializers for JSON (- j)
295299 * record - creating functions supporting default fields (- v)
296300 * user - specified data validators (- v)
297301
298- Recommended usage: %s (-t|-b|-j|-v|-dep|-list|-mel) example.atd" Sys. argv.(0 ) in
302+ Recommended usage : % s (- t|- b|- j|- v|- dep|- list |- mel) example .atd
303+
304+ Some options are deprecated . Use the environment variable `% s= true `
305+ to make their use fail and hence help clean - up your build scripts .
306+ |} Sys. argv.(0 ) fail_deprecated_variable in
299307 Arg. parse options (fun file -> files := file :: ! files) msg;
300308
301309 if (! unknown_field_handler <> None ) && ! mode = None then
0 commit comments