From c822531fde57b8bf6c3e7d111ab9e7bbf94cd58c Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Fri, 20 Sep 2024 16:50:45 -0600 Subject: [PATCH] Added check to remove duplicates in 'inspect' cmd --- cmd/inspect.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/inspect.go b/cmd/inspect.go index 2635b70..735fa7b 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/OpenCHAMI/configurator/pkg/generator" + "github.com/OpenCHAMI/configurator/pkg/util" "github.com/rodaine/table" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -26,11 +27,16 @@ var inspectCmd = &cobra.Command{ return strings.ToUpper(fmt.Sprintf(format, vals...)) } - // TODO: remove duplicate args from CLI + // remove duplicate clean paths from CLI + paths := make([]string, len(args)) + for _, path := range args { + paths = append(paths, filepath.Clean(path)) + } + paths = util.RemoveDuplicates(paths) // load specific plugins from positional args var generators = make(map[string]generator.Generator) - for _, path := range args { + for _, path := range paths { err := filepath.Walk(path, func(path string, info fs.FileInfo, err error) error { if err != nil { return err