Skip to content

Commit 43c2c52

Browse files
committed
wip
1 parent c2e7718 commit 43c2c52

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/client/opamSwitchCommand.ml

+12-5
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,20 @@ let create
295295
let simulate = OpamStateConfig.(!r.dryrun) || OpamClientConfig.(!r.show) in
296296
if OpamGlobalState.switch_exists gt switch then
297297
OpamConsole.error_and_exit `Bad_arguments
298-
"There already is an installed switch named %s"
298+
"There already is an installed switch named %s.\n\
299+
Please see https://opam.ocaml.org/doc/FAQ.html#switch-already-present"
299300
(OpamSwitch.to_string switch);
300301
if Sys.file_exists (OpamFilename.Dir.to_string comp_dir) then
301-
OpamConsole.error_and_exit `Bad_arguments
302-
"Directory %S already exists, please choose a different name"
303-
(OpamFilename.Dir.to_string comp_dir);
304-
let gt, st =
302+
if not (OpamFilename.dir_is_empty comp_dir) then
303+
OpamConsole.error_and_exit `Bad_arguments
304+
"Directory %S already exists, please choose a different name"
305+
(OpamFilename.Dir.to_string comp_dir)
306+
else
307+
if not (OpamConsole.confirm
308+
"Directory %S exitst and is empty, remove it?") then
309+
OpamConsole.error_and_exit `Aborted "Remove %S directory and recreate switch"
310+
else
311+
let gt, st =
305312
if not simulate then
306313
let gt =
307314
OpamSwitchAction.create_empty_switch gt ?synopsis ?repos ~invariant

0 commit comments

Comments
 (0)