From 838f064991a6868406b4a96167cec201f910f4fa Mon Sep 17 00:00:00 2001 From: Joop Kiefte Date: Thu, 28 Sep 2023 01:43:16 +0100 Subject: Correct menu in loop --- main.go | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 3432a3b..881f415 100644 --- a/main.go +++ b/main.go @@ -16,8 +16,10 @@ func main() { var table string var query string var args []string + var noninteractive bool if len(os.Args) > 1 { + noninteractive = true switch os.Args[1] { case "ls": // List tables choice = 1 @@ -85,21 +87,26 @@ Running debby with any other arguments will run it as a dolt command.` case 5: // Exit return - default: - // Reset choice - choice = 0 - // Print menu - fmt.Println("1. Read table names") - fmt.Println("2. Run query") - fmt.Println("3. Edit table") - fmt.Println("4. Execute Dolt command") - fmt.Println("5. Exit") - fmt.Print("Enter your choice: ") - - // Read user input - fmt.Scanln(&choice) } + // If noninteractive, exit + if noninteractive { + return + } + + // Reset choice + choice = 0 + // Print menu + fmt.Println("1. Read table names") + fmt.Println("2. Run query") + fmt.Println("3. Edit table") + fmt.Println("4. Execute Dolt command") + fmt.Println("5. Exit") + fmt.Print("Enter your choice: ") + + // Read user input + fmt.Scanln(&choice) + // Reset all variables except choice table = "" query = "" -- cgit v1.2.3-70-g09d2