TheMathemagicians/sevenkeys/cli/search.go

62 lines
1.6 KiB
Go
Raw Normal View History

package cli
import (
"database/sql"
"fmt"
"sevenkeys/logic"
)
var shouldRefreshSearch bool = true
func getSearchCriteria() logic.SearchCriteria {
var searchCriteria logic.SearchCriteria
searchCriteria.SetCode = GetStringResponse("Set code:")
searchCriteria.Foil = GetTriadicResponse("Foil (y/n/E):")
searchCriteria.Promo = GetTriadicResponse("Promo (y/n/E):")
searchCriteria.Language = GetStringResponse("Language:")
shouldRefreshSearch = true
return searchCriteria
}
func getTriadicDisplay(triadic logic.Triadic) string {
if triadic == logic.True {
return "True"
}
if triadic == logic.False {
return "False"
}
return "Either"
}
func showInsertSearchCriteria(insertSearchCriteria logic.SearchCriteria) {
fmt.Println("SEARCH CRITERIA")
setCodeDisplay := getInfoDisplay(insertSearchCriteria.SetCode)
foilDisplay := getTriadicDisplay(insertSearchCriteria.Foil)
promoDisplay := getTriadicDisplay(insertSearchCriteria.Promo)
languageDisplay := getInfoDisplay(insertSearchCriteria.Language)
fmt.Println("Set code:", setCodeDisplay)
fmt.Println("Foil:", foilDisplay)
fmt.Println("Promo:", promoDisplay)
fmt.Println("Language:", languageDisplay)
fmt.Print("\n")
}
func showSelectedCard() {
selectedCardDisplay := getInfoDisplay(selectedCardPrintingSearchLine)
fmt.Println("Selected card:", selectedCardDisplay)
}
func getSearchOptions(db *sql.DB, insertSearchCriteria logic.SearchCriteria) logic.InsertSearchOptions {
options, err := logic.GetAllSearchOptions(db, insertSearchCriteria)
logic.Check(err)
shouldRefreshSearch = false
return options
}