aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoop Kiefte <ikojba@gmail.com>2023-09-28 01:43:16 +0100
committerJoop Kiefte <ikojba@gmail.com>2023-09-28 01:43:16 +0100
commit838f064991a6868406b4a96167cec201f910f4fa (patch)
tree790d89075bbc9a8975d9b6dfb05b3d6915d7ff64
parent0f66418788c708da0f13915ac6e0b83c81d5c256 (diff)
Correct menu in loop
-rw-r--r--main.go31
1 files changed, 19 insertions, 12 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 = ""