Add filter flag

This commit is contained in:
2025-03-28 11:20:35 +01:00
parent e8f16dda2b
commit 8a86ae2f40
3 changed files with 21 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"modify/logger"
"os"
"strings"
"github.com/bmatcuk/doublestar/v4"
"gopkg.in/yaml.v3"
@@ -206,3 +207,16 @@ func CountGlobsBeforeDedup(commands []ModifyCommand) int {
}
return count
}
func FilterCommands(commands []ModifyCommand, filter string) []ModifyCommand {
filteredCommands := []ModifyCommand{}
filters := strings.Split(filter, ",")
for _, cmd := range commands {
for _, filter := range filters {
if strings.Contains(cmd.Name, filter) {
filteredCommands = append(filteredCommands, cmd)
}
}
}
return filteredCommands
}