Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pjaudiomv/awsd

go 1.16
go 1.18

require github.com/manifoldco/promptui v0.9.0

Expand Down
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"bufio"
"fmt"
"github.com/manifoldco/promptui"
"github.com/manifoldco/promptui/list"
"log"
"os"
"regexp"
"sort"
"strings"
)

const (
Expand All @@ -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" {
Expand All @@ -39,7 +47,9 @@ func main() {
Inactive: " {{.}}",
Selected: " {{ . | cyan }}",
},
Stdout: &bellSkipper{},
Searcher: newPromptUISearcher(profiles),
StartInSearchMode: true,
Stdout: &bellSkipper{},
}

_, result, err := prompt.Run()
Expand Down Expand Up @@ -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)
}
Expand Down