Skip to content

Commit ee016cf

Browse files
authored
Don't append default profile if it already exists (#7)
1 parent 18a60bb commit ee016cf

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.0.4 (October 4, 2023)
2+
* Don't append default profile if it already exists.
3+
14
## v0.0.3 (September 22, 2023)
25
* Added additional error checking.
36

main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818
CyanColor = "\033[0;36m%s\033[0m"
1919
)
2020

21-
var version string = "v0.0.3"
21+
var version string = "v0.0.4"
2222

2323
func newPromptUISearcher(items []string) list.Searcher {
2424
return func(searchInput string, itemIndex int) bool {
@@ -116,11 +116,20 @@ func getProfiles(profileFileLocation string) []string {
116116
log.Fatal(err)
117117
}
118118

119-
profiles = append(profiles, "default")
119+
profiles = appendIfNotExists(profiles, "default")
120120
sort.Strings(profiles)
121121
return profiles
122122
}
123123

124+
func appendIfNotExists(slice []string, s string) []string {
125+
for _, v := range slice {
126+
if v == s {
127+
return slice
128+
}
129+
}
130+
return append(slice, s)
131+
}
132+
124133
func getenv(key, fallback string) string {
125134
value := os.Getenv(key)
126135
if len(value) == 0 {

0 commit comments

Comments
 (0)