From 2ecb448e29f22ddf06bff1100592e010a32793a8 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 16 Sep 2024 17:59:44 +0100 Subject: [PATCH] Bugfix: Display selected card when inserting --- sevenkeys/cli/mainui.go | 3 ++- sevenkeys/logic/search.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sevenkeys/cli/mainui.go b/sevenkeys/cli/mainui.go index ffbbfa9..05bd77d 100644 --- a/sevenkeys/cli/mainui.go +++ b/sevenkeys/cli/mainui.go @@ -71,8 +71,9 @@ func MainCliLoop(db *sql.DB) { var previousCardPrintingId = cardLocation.CardPrintingId - pk, err := logic.GenericSearch(insertSearchOptions) + pk, searchLine, err := logic.GenericSearch(insertSearchOptions) cardLocation.CardPrintingId = pk + selectedCardPrintingSearchLine = searchLine var exitError *exec.ExitError if errors.As(err, &exitError) { diff --git a/sevenkeys/logic/search.go b/sevenkeys/logic/search.go index 38ff66d..a15b252 100644 --- a/sevenkeys/logic/search.go +++ b/sevenkeys/logic/search.go @@ -61,7 +61,7 @@ func GetAllSearchOptions(db *sql.DB, searchCriteria SearchCriteria) (InsertSearc return searchOptions, err } -func GenericSearch[pk string | int](options map[string]pk) (pk, error) { +func GenericSearch[pk string | int](options map[string]pk) (pk, string, error) { var value pk cmd := exec.Command("fzf") @@ -69,7 +69,7 @@ func GenericSearch[pk string | int](options map[string]pk) (pk, error) { fzfStdin, err := cmd.StdinPipe() if err != nil { - return value, err + return value, "", err } go func() { @@ -81,10 +81,10 @@ func GenericSearch[pk string | int](options map[string]pk) (pk, error) { fzfOutput, err := cmd.Output() if err != nil { - return value, err + return value, "", err } searchResult := strings.TrimSuffix(string(fzfOutput), "\n") value = options[searchResult] - return value, nil + return value, searchResult, nil }