Add search filtering UI

This commit is contained in:
The Magician 2024-06-11 17:02:02 +01:00
parent cdf0a562fc
commit ed4c01ce49
2 changed files with 24 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"sevenkeys/logic"
"strings"
)
@ -22,3 +23,16 @@ func GetYesNoResponse(prompt string) bool {
response := GetStringResponse(prompt)
return strings.ToUpper(response) == "Y"
}
func GetTriadicResponse(prompt string) logic.Triadic {
response := GetStringResponse(prompt)
switch strings.ToUpper(response) {
case "Y":
return logic.True
case "N":
return logic.False
default:
return logic.Either
}
}

View File

@ -24,6 +24,13 @@ var (
searchOptions logic.SearchOptions
)
func getSearchCriteria() {
searchCriteria.SetCode = GetStringResponse("Set code:")
searchCriteria.Foil = GetTriadicResponse("Foil (y/n/E):")
searchCriteria.Promo = GetTriadicResponse("Promo (y/n/E):")
searchCriteria.Language = GetStringResponse("Language:")
}
func getSearchOptions(db *sql.DB) {
if searchOptions == nil {
fmt.Println("LOADING")
@ -96,6 +103,9 @@ func StashCliLoop(db *sql.DB) {
case "storage":
GetStorageOptions()
break
case "criteria":
getSearchCriteria()
break
case "search":
getSearchOptions(db)
var err error