Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
removed function requesting user input to confirm deleting files in d…
Browse files Browse the repository at this point in the history
…irectory if the force flage isn't used as they are a p.i.t.a

Signed-off-by: Holly Hunt <[email protected]>
  • Loading branch information
Wyvinar committed Jun 7, 2024
1 parent 894bdde commit 9c171f2
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions openapi2beans/pkg/generator/yaml2java.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package generator

import (
"fmt"
"log"
"strings"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9c171f2

Please sign in to comment.