Add search filtering UI
This commit is contained in:
parent
cdf0a562fc
commit
ed4c01ce49
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue