Skip to content

Commit

Permalink
Added ability to search withing projects list (using /, vi-like)
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Oct 27, 2020
1 parent 1427a6f commit 7f28a5b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/main.go
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/signal"
"strconv"
"strings"

"github.com/eko/monday/internal/runtime"
"github.com/eko/monday/pkg/config"
Expand Down Expand Up @@ -50,8 +51,7 @@ func main() {
return
}

choice := selectProject(conf)
runProject(conf, choice)
runProject(conf, selectProject(conf))

handleExitSignal()
},
Expand All @@ -75,10 +75,18 @@ func main() {
}

func selectProject(conf *config.Config) string {
projects := conf.GetProjectNames()

prompt := promptui.Select{
Label: "Which project do you want to work on?",
Items: conf.GetProjectNames(),
Items: projects,
Size: 20,
Searcher: func(input string, index int) bool {
return strings.Contains(
strings.Replace(strings.ToLower(projects[index]), " ", "", -1),
strings.Replace(strings.ToLower(input), " ", "", -1),
)
},
}

_, choice, err := prompt.Run()
Expand Down

0 comments on commit 7f28a5b

Please sign in to comment.