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 }