12345678910111213141516171819202122232425262728293031323334353637openColoropen!Core(** [get_version_of_ocamlformat] returns the version of installed ocamlformat. *)letget_version_of_ocamlformat=letinp=Unix.open_process_in"ocamlformat --version"inletr=matchIn_channel.input_lineinpwith|Somes->s|None->failwith"Command ocamlformat not found."inIn_channel.closeinp;r;;(** [preset_config] returns the configuration of [.ocamlformat]. *)letpreset_config=letpresets=["#this configuration is generated by dump_ocamlformat";"profile = janestreet";"version = "^get_version_of_ocamlformat]inString.concat~sep:"\n"presets;;(** [dump_preset_config filename] dumps the configuration into [filename]. *)letdump_preset_configfilename=matchSys.is_filefilenamewith|`Yes->".ocamlformat has been updated."|>paint_as_cyan|>print_endline;Out_channel.write_allfilename~data:preset_config|`No->".ocamlformat has been created."|>paint_as_cyan|>print_endline;Out_channel.write_allfilename~data:preset_config|`Unknown->"ERROR: .ocamlformat may exist."|>paint_as_red|>print_endline;;