mirror of
https://github.com/onyx-and-iris/ignr.git
synced 2026-04-18 07:13:33 +00:00
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:
21
filter.go
Normal file
21
filter.go
Normal 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user