@@ -116,23 +116,35 @@ let enable_outside_detected_project =
116116 (List. map File_system. project_root_witness ~f: (fun name ->
117117 Format. sprintf " $(b,%s)" name ) )
118118 in
119- let doc =
120- Format. sprintf
121- " Read $(b,.ocamlformat) config files outside the current project when \
122- no project root has been detected for the input file. The project \
123- root of an input file is taken to be the nearest ancestor directory \
124- that contains a %s file. If $(b,.ocamlformat) config files are \
125- located in the same directory or parents they are applied, if no \
126- $(b,.ocamlformat) file is found then the global configuration \
127- defined in $(b,\\ $XDG_CONFIG_HOME/.ocamlformat) (or in \
128- $(b,\\ $HOME/.config/.ocamlformat) if $(b,\\ $XDG_CONFIG_HOME) is \
129- undefined) is applied."
130- witness
119+ let enable =
120+ let doc_enable =
121+ Format. sprintf
122+ " Read $(b,.ocamlformat) config files outside the current project \
123+ when no project root has been detected for the input file. The \
124+ project root of an input file is taken to be the nearest ancestor \
125+ directory that contains a %s file. If $(b,.ocamlformat) config \
126+ files are located in the same directory or parents they are \
127+ applied, if no $(b,.ocamlformat) file is found then the global \
128+ configuration defined in $(b,\\ $XDG_CONFIG_HOME/.ocamlformat) (or \
129+ in $(b,\\ $HOME/.config/.ocamlformat) if $(b,\\ $XDG_CONFIG_HOME) is \
130+ undefined) is applied."
131+ witness
132+ in
133+ Arg. info [" enable-outside-detected-project" ] ~doc: doc_enable ~docs
134+ in
135+ let disable =
136+ let doc_disable =
137+ " If no $(b,.ocamlformat) config files have been detected, disable the \
138+ formatting. OCamlFormat is disabled outside of a detected project by \
139+ default, to enable the opposite behavior use \
140+ $(b,--enable-outside-detected-project)."
141+ in
142+ Arg. info [" disable-outside-detected-project" ] ~doc: doc_disable ~docs
131143 in
132144 Term. (
133145 const (fun enable_outside_detected_project conf ->
134146 {conf with enable_outside_detected_project} )
135- $ Arg. (value & flag & info [ " enable-outside-detected-project " ] ~doc ~docs ) )
147+ $ Arg. (value & vflag false [( true , enable); ( false , disable)] ) )
136148
137149let inplace =
138150 let doc = " Format in-place, overwriting input file(s)." in
0 commit comments