View raw

1 (** The [ogit-write-config] executable. 2 3 Writes a configuration file containing every variable at its default value. 4 Intended for bootstrapping a new deployment. The destination defaults to 5 the path {!Ogit.Config.load} reads from; an existing file is never 6 overwritten unless [--force] is given. *) 7 8 let usage = "Usage: ogit-write-config [--output <path>] [--force]" 9 10 let () = 11 let output = ref None in 12 let force = ref false in 13 let speclist = 14 [ 15 ( "--output", 16 Arg.String (fun path -> output := Some path), 17 "<path> Destination file (defaults to the standard configuration path)" 18 ); 19 ("--force", Arg.Set force, " Overwrite the destination when it exists"); 20 ] 21 in 22 Arg.parse speclist (fun _ -> ()) usage; 23 let file = 24 Option.value !output ~default:(Ogit.Config.locate_config_file ()) 25 in 26 if (not !force) && Sys.file_exists file then ( 27 Printf.eprintf "refusing to overwrite %s (use --force)\n" file; 28 exit 1) 29 else Ogit.Config.(default |> to_table |> write_file ~file) 30