Skip to content

Commit

Permalink
Don't append default profile if it already exists (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv authored Oct 4, 2023
1 parent 18a60bb commit ee016cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.0.4 (October 4, 2023)
* Don't append default profile if it already exists.

## v0.0.3 (September 22, 2023)
* Added additional error checking.

Expand Down
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
CyanColor = "\033[0;36m%s\033[0m"
)

var version string = "v0.0.3"
var version string = "v0.0.4"

func newPromptUISearcher(items []string) list.Searcher {
return func(searchInput string, itemIndex int) bool {
Expand Down Expand Up @@ -116,11 +116,20 @@ func getProfiles(profileFileLocation string) []string {
log.Fatal(err)
}

profiles = append(profiles, "default")
profiles = appendIfNotExists(profiles, "default")
sort.Strings(profiles)
return profiles
}

func appendIfNotExists(slice []string, s string) []string {
for _, v := range slice {
if v == s {
return slice
}
}
return append(slice, s)
}

func getenv(key, fallback string) string {
value := os.Getenv(key)
if len(value) == 0 {
Expand Down

0 comments on commit ee016cf

Please sign in to comment.