2024-05-27 12:29:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-05-27 16:45:22 +00:00
|
|
|
"io"
|
2024-05-27 12:29:00 +00:00
|
|
|
"log"
|
2024-05-27 16:45:22 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2024-05-27 12:29:00 +00:00
|
|
|
"sevenkeys/database"
|
|
|
|
"sevenkeys/database/operations"
|
|
|
|
)
|
|
|
|
|
2024-05-27 16:45:22 +00:00
|
|
|
func check(err error) {
|
2024-05-27 12:29:00 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2024-05-27 16:45:22 +00:00
|
|
|
}
|
2024-05-27 12:29:00 +00:00
|
|
|
|
2024-05-27 16:45:22 +00:00
|
|
|
func main() {
|
|
|
|
db := database.GetDatabaseFromConfig("config.json")
|
|
|
|
cardSearchOptions, err := operations.GetCardSearchOptions(db)
|
|
|
|
check(err)
|
|
|
|
|
|
|
|
cmd := exec.Command("fzf")
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
|
|
|
|
fzfStdin, err := cmd.StdinPipe()
|
|
|
|
check(err)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer fzfStdin.Close()
|
|
|
|
for _, option := range cardSearchOptions {
|
|
|
|
io.WriteString(fzfStdin, option+"\n")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
fzfOutput, err := cmd.Output()
|
|
|
|
check(err)
|
|
|
|
|
|
|
|
fmt.Println("Output:", string(fzfOutput))
|
2024-05-27 12:29:00 +00:00
|
|
|
}
|