diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9508afa..68458c2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-go@v2 with: stable: 'false' - go-version: '1.17.1' + go-version: '1.18.2' - name: Lint run: | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1 diff --git a/go.mod b/go.mod index d0370a3..1142566 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pjaudiomv/awsd -go 1.16 +go 1.18 require github.com/manifoldco/promptui v0.9.0 diff --git a/main.go b/main.go index f7508c6..4eb4e32 100644 --- a/main.go +++ b/main.go @@ -4,10 +4,12 @@ import ( "bufio" "fmt" "github.com/manifoldco/promptui" + "github.com/manifoldco/promptui/list" "log" "os" "regexp" "sort" + "strings" ) const ( @@ -16,7 +18,13 @@ const ( CyanColor = "\033[0;36m%s\033[0m" ) -var version string = "v0.0.1" +var version string = "v0.0.2" + +func newPromptUISearcher(items []string) list.Searcher { + return func(searchInput string, itemIndex int) bool { + return strings.Contains(strings.ToLower(items[itemIndex]), strings.ToLower(searchInput)) + } +} func main() { if len(os.Args) > 1 && os.Args[1] == "version" { @@ -39,7 +47,9 @@ func main() { Inactive: " {{.}}", Selected: " {{ . | cyan }}", }, - Stdout: &bellSkipper{}, + Searcher: newPromptUISearcher(profiles), + StartInSearchMode: true, + Stdout: &bellSkipper{}, } _, result, err := prompt.Run() @@ -85,7 +95,7 @@ func getProfiles(profileFileLocation string) []string { for scanner.Scan() { if r.MatchString(scanner.Text()) { s := scanner.Text() - reg := regexp.MustCompile(`(\[profile )|(\])`) + reg := regexp.MustCompile(`(\[profile )|(])`) res := reg.ReplaceAllString(s, "") profiles = append(profiles, res) }