TheMathemagicians/sevenkeys/cmd/printinglist/main.go

42 lines
649 B
Go
Raw Normal View History

2024-05-27 12:29:00 +00:00
package main
import (
"fmt"
"io"
2024-05-27 12:29:00 +00:00
"log"
"os"
"os/exec"
2024-05-27 12:29:00 +00:00
"sevenkeys/database"
"sevenkeys/database/operations"
)
func check(err error) {
2024-05-27 12:29:00 +00:00
if err != nil {
log.Fatal(err)
}
}
2024-05-27 12:29:00 +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
}