From f9835d90fa542658250b963d97a8386bae1815e8 Mon Sep 17 00:00:00 2001 From: Shreyas Prabhu <shreyasprabhu26@gmail.com> Date: Fri, 16 May 2025 14:44:48 +0530 Subject: [PATCH] Refactor vq --- main.go | 58 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/main.go b/main.go index f80d87c..2bac49b 100644 --- a/main.go +++ b/main.go @@ -123,34 +123,7 @@ func main() { fmt.Printf("%d. %s (Type: %s)\n", i+1, conn.Name, connType) } - case "delete-connection": - // If connection name not provided via command line, get it from config - connNameToDelete := *connectionName - if connNameToDelete == "" { - // If there's only one connection in config, use that - if len(cfg.Connections) == 1 { - connNameToDelete = cfg.Connections[0].Name - fmt.Printf("Using connection name from config: %s\n", connNameToDelete) - } else if len(cfg.Connections) > 1 { - // If multiple connections, show the available options - fmt.Println("Multiple connections found in config. Please specify which one to delete with --name flag:") - for i, conn := range cfg.Connections { - fmt.Printf("%d. %s\n", i+1, conn.Name) - } - os.Exit(1) - } else { - log.Fatalf("No connections found in config file") - } - } - - log.Printf("Deleting connection %s in project %s (location: %s)", - connNameToDelete, projectIDValue, locationValue) - - err := client.DeleteConnection(projectIDValue, locationValue, connNameToDelete) - if err != nil { - log.Fatalf("Failed to delete connection: %v", err) - } - fmt.Printf("Successfully deleted connection: %s\n", connNameToDelete) + case "list-linkable-repos": // If connection name not provided via command line, get it from config @@ -191,6 +164,35 @@ func main() { fmt.Println() } } + + case "delete-connection": + // If connection name not provided via command line, get it from config + connNameToDelete := *connectionName + if connNameToDelete == "" { + // If there's only one connection in config, use that + if len(cfg.Connections) == 1 { + connNameToDelete = cfg.Connections[0].Name + fmt.Printf("Using connection name from config: %s\n", connNameToDelete) + } else if len(cfg.Connections) > 1 { + // If multiple connections, show the available options + fmt.Println("Multiple connections found in config. Please specify which one to delete with --name flag:") + for i, conn := range cfg.Connections { + fmt.Printf("%d. %s\n", i+1, conn.Name) + } + os.Exit(1) + } else { + log.Fatalf("No connections found in config file") + } + } + + log.Printf("Deleting connection %s in project %s (location: %s)", + connNameToDelete, projectIDValue, locationValue) + + err := client.DeleteConnection(projectIDValue, locationValue, connNameToDelete) + if err != nil { + log.Fatalf("Failed to delete connection: %v", err) + } + fmt.Printf("Successfully deleted connection: %s\n", connNameToDelete) case "inspect": // This action provides detailed inspection of a connection's configuration and status -- GitLab