From ed0393f3173ad72ee443907c84ff989dc5bffd61 Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Mon, 23 Sep 2024 19:03:22 -0400 Subject: [PATCH] add duplicate command warning --- core/commandline/shell.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/commandline/shell.go b/core/commandline/shell.go index ef5f10b2da..ff9e5dd1a3 100644 --- a/core/commandline/shell.go +++ b/core/commandline/shell.go @@ -3,6 +3,7 @@ package commandline import ( "context" "fmt" + "k8s.io/apimachinery/pkg/util/sets" "os" "os/signal" "os/user" @@ -90,11 +91,18 @@ func GenerateShellCommand(shellCommands []*cli.Command) *cli.Command { // pruneShellCommands gets a list of commands including the shell command. func pruneShellCommands(commands []*cli.Command) (prunedCommands []*cli.Command) { // initialize shell commands + nameSet := sets.NewString() for _, command := range commands { if command.Name != shellCommandName { prunedCommands = append(prunedCommands, command) } + if !nameSet.Has(command.Name) { + fmt.Printf("Command %s already exists, skipping\n", command.Name) + } + + nameSet.Insert(command.Name) } + return prunedCommands }