Bugfix: Display selected card when inserting

This commit is contained in:
The Magician 2024-09-16 17:59:44 +01:00
parent b2946d00e2
commit 2ecb448e29
2 changed files with 6 additions and 5 deletions

View File

@ -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) {

View File

@ -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
}