From f557b032582fccbfac7b1b9f7e28d5508c4609bf Mon Sep 17 00:00:00 2001 From: Michael Poutre Date: Fri, 27 May 2022 15:28:31 -0700 Subject: [PATCH 1/3] feat: Update to go1.18 --- .github/workflows/pull-request.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From d8eadc68bf27f9558192c75c1025d0acde0b1df9 Mon Sep 17 00:00:00 2001 From: Michael Poutre Date: Fri, 27 May 2022 15:33:12 -0700 Subject: [PATCH 2/3] feat: Add searcher to prompt This allows users to search for a specific profile rather than scrolling through their entire list --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index f7508c6..66cf38e 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() From 3111bfec927f30c09f252c6af9b0bddc5007a41c Mon Sep 17 00:00:00 2001 From: Michael Poutre Date: Fri, 27 May 2022 15:45:48 -0700 Subject: [PATCH 3/3] refactor: Remove unnecessary RegEx escape --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 66cf38e..4eb4e32 100644 --- a/main.go +++ b/main.go @@ -95,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) }