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" "bufio"
"fmt" "fmt"
"os" "os"
"sevenkeys/logic"
"strings" "strings"
) )
@ -22,3 +23,16 @@ func GetYesNoResponse(prompt string) bool {
response := GetStringResponse(prompt) response := GetStringResponse(prompt)
return strings.ToUpper(response) == "Y" 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 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) { func getSearchOptions(db *sql.DB) {
if searchOptions == nil { if searchOptions == nil {
fmt.Println("LOADING") fmt.Println("LOADING")
@ -96,6 +103,9 @@ func StashCliLoop(db *sql.DB) {
case "storage": case "storage":
GetStorageOptions() GetStorageOptions()
break break
case "criteria":
getSearchCriteria()
break
case "search": case "search":
getSearchOptions(db) getSearchOptions(db)
var err error var err error