handleCreationApp and createUnikraftApp corrected

This commit is contained in:
Rob1103 2022-10-14 18:48:49 +02:00
parent 6c22d12640
commit d641975f97

View file

@ -109,7 +109,10 @@ func createUnikraftApp(programName, workspacePath string) (*string, error) {
if !created { if !created {
u.PrintWarning(appFolder + " already exists.") u.PrintWarning(appFolder + " already exists.")
handleCreationApp(&appFolder) appFolder = handleCreationApp(appFolder)
if _, err := u.CreateFolder(appFolder); err != nil {
return nil, err
}
} }
return &appFolder, nil return &appFolder, nil
@ -117,7 +120,7 @@ func createUnikraftApp(programName, workspacePath string) (*string, error) {
// -----------------------------Create App folder------------------------------- // -----------------------------Create App folder-------------------------------
func handleCreationApp(appFolder *string) { func handleCreationApp(appFolder string) string {
fmt.Println("Make your choice:\n1: Copy and overwrite files\n2: " + fmt.Println("Make your choice:\n1: Copy and overwrite files\n2: " +
"Enter manually the name of the folder\n3: exit program") "Enter manually the name of the folder\n3: exit program")
var input int var input int
@ -128,13 +131,13 @@ func handleCreationApp(appFolder *string) {
} else { } else {
switch input { switch input {
case 1: case 1:
return return appFolder
case 2: case 2:
fmt.Print("Enter text: ") fmt.Print("Enter text: ")
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString('\n') text, _ := reader.ReadString('\n')
appFolder = &text appFolder = strings.Split(text, "\n")[0] + u.SEP
return return appFolder
case 3: case 3:
os.Exit(1) os.Exit(1)
default: default:
@ -142,6 +145,8 @@ func handleCreationApp(appFolder *string) {
} }
} }
} }
return appFolder
} }
// -------------------------MOVE FILES TO APP FOLDER---------------------------- // -------------------------MOVE FILES TO APP FOLDER----------------------------