Only get options when searching
This commit is contained in:
parent
a6c2f73637
commit
74219fa7aa
|
@ -3,10 +3,9 @@ package cli
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sevenkeys/logic"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MainCliLoop(db *sql.DB, searchOptions logic.SearchOptions) {
|
func MainCliLoop(db *sql.DB) {
|
||||||
var command string
|
var command string
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -19,7 +18,7 @@ func MainCliLoop(db *sql.DB, searchOptions logic.SearchOptions) {
|
||||||
ShowSplashScreen()
|
ShowSplashScreen()
|
||||||
break
|
break
|
||||||
case "stash":
|
case "stash":
|
||||||
StashCliLoop(db, searchOptions)
|
StashCliLoop(db)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unrecognized command:", command)
|
fmt.Println("Unrecognized command:", command)
|
||||||
|
|
|
@ -14,10 +14,35 @@ var (
|
||||||
storageBoxLabel string
|
storageBoxLabel string
|
||||||
source string
|
source string
|
||||||
cardCondition string
|
cardCondition string
|
||||||
|
|
||||||
|
searchOptions logic.SearchOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getSearchOptions(db *sql.DB) {
|
||||||
|
if searchOptions == nil {
|
||||||
|
fmt.Println("LOADING")
|
||||||
|
options, err := logic.GetAllSearchOptions(db)
|
||||||
|
logic.Check(err)
|
||||||
|
searchOptions = options
|
||||||
|
fmt.Println("READY")
|
||||||
|
fmt.Println("RUN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getInfoDisplay(info string) string {
|
||||||
|
if info == "" {
|
||||||
|
return "[EMPTY]"
|
||||||
|
}
|
||||||
|
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
func ShowStorageInfo() {
|
func ShowStorageInfo() {
|
||||||
fmt.Println("Storage location:", storageBoxLabel, "|", "Source:", source)
|
storageBoxDisplay := getInfoDisplay(storageBoxLabel)
|
||||||
|
sourceDisplay := getInfoDisplay(source)
|
||||||
|
conditionDisplay := getInfoDisplay(cardCondition)
|
||||||
|
|
||||||
|
fmt.Println("Storage location:", storageBoxDisplay, "|", "Source:", sourceDisplay, "|", "Condition:", conditionDisplay)
|
||||||
|
|
||||||
if selectedCardPrintingId != "" {
|
if selectedCardPrintingId != "" {
|
||||||
fmt.Println("Selected card:", selectedCardPrintingSearchLine)
|
fmt.Println("Selected card:", selectedCardPrintingSearchLine)
|
||||||
|
@ -46,10 +71,12 @@ func InsertSelectedCard(db *sql.DB) {
|
||||||
Source: source,
|
Source: source,
|
||||||
}
|
}
|
||||||
|
|
||||||
logic.StoreCard(db, storageLocation)
|
err := logic.StoreCard(db, storageLocation)
|
||||||
|
logic.Check(err)
|
||||||
|
fmt.Println("Inserted card")
|
||||||
}
|
}
|
||||||
|
|
||||||
func StashCliLoop(db *sql.DB, searchOptions logic.SearchOptions) {
|
func StashCliLoop(db *sql.DB) {
|
||||||
var command string
|
var command string
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -63,6 +90,7 @@ func StashCliLoop(db *sql.DB, searchOptions logic.SearchOptions) {
|
||||||
GetStorageOptions()
|
GetStorageOptions()
|
||||||
break
|
break
|
||||||
case "search":
|
case "search":
|
||||||
|
getSearchOptions(db)
|
||||||
var err error
|
var err error
|
||||||
selectedCardPrintingId, selectedCardPrintingSearchLine, err = logic.Search(searchOptions)
|
selectedCardPrintingId, selectedCardPrintingSearchLine, err = logic.Search(searchOptions)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"sevenkeys/cli"
|
"sevenkeys/cli"
|
||||||
"sevenkeys/database"
|
"sevenkeys/database"
|
||||||
"sevenkeys/figlet"
|
"sevenkeys/figlet"
|
||||||
"sevenkeys/logic"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var searchOptions logic.SearchOptions
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
db := database.GetDatabaseFromConfig("config.json")
|
db := database.GetDatabaseFromConfig("config.json")
|
||||||
figlet.ReadFigletFonts()
|
figlet.ReadFigletFonts()
|
||||||
|
@ -18,13 +14,7 @@ func main() {
|
||||||
|
|
||||||
cli.RunUpdateCheck(db)
|
cli.RunUpdateCheck(db)
|
||||||
|
|
||||||
fmt.Println("LOADING")
|
cli.MainCliLoop(db)
|
||||||
searchOptions, err := logic.GetAllSearchOptions(db)
|
|
||||||
logic.Check(err)
|
|
||||||
fmt.Println("READY")
|
|
||||||
fmt.Println("RUN")
|
|
||||||
|
|
||||||
cli.MainCliLoop(db, searchOptions)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var selectedCardId string
|
var selectedCardId string
|
||||||
|
|
Loading…
Reference in New Issue