replace huh with promptui

- it gives more control over filtering

add --filter/-f flag, this allows configuration over a prefix vs contains filter

update the README to reflect changes
This commit is contained in:
2025-06-18 03:31:34 +01:00
parent 39f762c0e6
commit 70b1c373ae
9 changed files with 254 additions and 117 deletions

21
filter.go Normal file
View File

@@ -0,0 +1,21 @@
package main
import (
"strings"
"github.com/spf13/viper"
)
// filterFunc returns a function that filters templates based on the specified filter type.
func filterFunc(templates []string) func(input string, index int) bool {
switch viper.GetString("filter") {
case "contains":
return func(input string, index int) bool {
return strings.Contains(strings.ToLower(templates[index]), strings.ToLower(input))
}
default:
return func(input string, index int) bool {
return strings.HasPrefix(strings.ToLower(templates[index]), strings.ToLower(input))
}
}
}