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