diff options
author | Joop Kiefte <ikojba@gmail.com> | 2023-09-28 01:43:16 +0100 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2023-09-28 01:43:16 +0100 |
commit | 838f064991a6868406b4a96167cec201f910f4fa (patch) | |
tree | 790d89075bbc9a8975d9b6dfb05b3d6915d7ff64 | |
parent | 0f66418788c708da0f13915ac6e0b83c81d5c256 (diff) |
Correct menu in loop
-rw-r--r-- | main.go | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -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 = "" |