From 9c171f20f79baeebdf90ec94ae37330c2ac91927 Mon Sep 17 00:00:00 2001 From: Holly Hunt Date: Fri, 7 Jun 2024 09:59:37 +0100 Subject: [PATCH] removed function requesting user input to confirm deleting files in directory if the force flage isn't used as they are a p.i.t.a Signed-off-by: Holly Hunt --- openapi2beans/pkg/generator/yaml2java.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/openapi2beans/pkg/generator/yaml2java.go b/openapi2beans/pkg/generator/yaml2java.go index 144c3b1..13c0545 100644 --- a/openapi2beans/pkg/generator/yaml2java.go +++ b/openapi2beans/pkg/generator/yaml2java.go @@ -6,7 +6,6 @@ package generator import ( - "fmt" "log" "strings" @@ -51,7 +50,7 @@ func generateDirectories(fs files.FileSystem, storeFilepath string, force bool) if err == nil { if exists { if !force { - err = requestDeletionAffirmation(storeFilepath) + err = openapi2beans_errors.NewError("generateDirectories: files located in directory requested to to produce beans in: %s", storeFilepath) } if err == nil { err = deleteAllJavaFiles(fs, storeFilepath) @@ -84,24 +83,6 @@ func generateStoreFilepath(outputFilepath string, packageName string) string { return outputFilepath + packageFilepath } -func requestDeletionAffirmation(storeFilepath string) error { - var err error - var userSure string - - fmt.Printf(`Directory already exists. -Do you wish to continue and delete already existing files in location: %s? -`, storeFilepath) - for strings.ToLower(userSure) != "y" && strings.ToLower(userSure) != "n" { - fmt.Print("(y/n): ") - fmt.Scan(&userSure) - } - if userSure == "n" { - err = openapi2beans_errors.NewError("generateDirectories: permission not given to delete java files in %s", storeFilepath) - } - - return err -} - func deleteAllJavaFiles(fs files.FileSystem, storeFilepath string) error { filepaths, err := fs.GetAllFilePaths(storeFilepath) for _, filepath := range filepaths {