(** The [ogit-write-config] executable. Writes a configuration file containing every variable at its default value. Intended for bootstrapping a new deployment. The destination defaults to the path {!Ogit.Config.load} reads from; an existing file is never overwritten unless [--force] is given. *) let usage = "Usage: ogit-write-config [--output ] [--force]" let () = let output = ref None in let force = ref false in let speclist = [ ( "--output", Arg.String (fun path -> output := Some path), " Destination file (defaults to the standard configuration path)" ); ("--force", Arg.Set force, " Overwrite the destination when it exists"); ] in Arg.parse speclist (fun _ -> ()) usage; let file = Option.value !output ~default:(Ogit.Config.locate_config_file ()) in if (not !force) && Sys.file_exists file then ( Printf.eprintf "refusing to overwrite %s (use --force)\n" file; exit 1) else Ogit.Config.(default |> to_table |> write_file ~file)