From 43c2c5279739b84213a4f1c6cb51c56e04c230dd Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 8 Sep 2022 12:25:37 +0200 Subject: [PATCH] wip --- src/client/opamSwitchCommand.ml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/client/opamSwitchCommand.ml b/src/client/opamSwitchCommand.ml index de1254e093c..9ca5aed7b8e 100644 --- a/src/client/opamSwitchCommand.ml +++ b/src/client/opamSwitchCommand.ml @@ -295,13 +295,20 @@ let create let simulate = OpamStateConfig.(!r.dryrun) || OpamClientConfig.(!r.show) in if OpamGlobalState.switch_exists gt switch then OpamConsole.error_and_exit `Bad_arguments - "There already is an installed switch named %s" + "There already is an installed switch named %s.\n\ + Please see https://opam.ocaml.org/doc/FAQ.html#switch-already-present" (OpamSwitch.to_string switch); if Sys.file_exists (OpamFilename.Dir.to_string comp_dir) then - OpamConsole.error_and_exit `Bad_arguments - "Directory %S already exists, please choose a different name" - (OpamFilename.Dir.to_string comp_dir); - let gt, st = + if not (OpamFilename.dir_is_empty comp_dir) then + OpamConsole.error_and_exit `Bad_arguments + "Directory %S already exists, please choose a different name" + (OpamFilename.Dir.to_string comp_dir) + else + if not (OpamConsole.confirm + "Directory %S exitst and is empty, remove it?") then + OpamConsole.error_and_exit `Aborted "Remove %S directory and recreate switch" + else + let gt, st = if not simulate then let gt = OpamSwitchAction.create_empty_switch gt ?synopsis ?repos ~invariant