36 lines
679 B
Go
36 lines
679 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/nicklaw5/helix/v2"
|
|
)
|
|
|
|
func searchGames(client *helix.Client, searchTerms []string) ([]helix.Game, error) {
|
|
resp, err := client.GetGames(&helix.GamesParams{
|
|
Names: searchTerms,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// TODO: Pagination and such
|
|
|
|
return resp.Data.Games, nil
|
|
}
|
|
|
|
func printGames(client *helix.Client, searchTerms []string) error {
|
|
games, err := searchGames(client, searchTerms)
|
|
if err != nil {
|
|
log.Fatalf("Error while seardching for games %v\n", searchTerms)
|
|
return err
|
|
}
|
|
|
|
// TODO: Pagination and such ?
|
|
for _, game := range games {
|
|
fmt.Printf("[%v] %v\n", game.ID, game.Name)
|
|
}
|
|
|
|
return nil
|
|
}
|