-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (34 loc) · 755 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"bufio"
"fmt"
"os"
"time"
"github.com/mtslzr/pokeapi-go"
"github.com/mtslzr/pokeapi-go/structs"
"github.com/planetquack1/pokedexcli/internal/pokecache"
)
func main() {
c := pokecache.NewCache(5 * time.Second)
p, err := pokeapi.Pokemon("1")
if err != nil {
fmt.Println("Error connecting to PokeAPI server")
}
cfg := Config{
cache: &c,
pokedex: make(map[string]structs.Pokemon),
endpoint: "location",
location: "",
pokemon: p, // default
commandType: "map",
limit: 20,
page: -1,
}
fmt.Printf("Pokedex > ")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
cmd := matchCommand(scanner.Text(), &cfg)
cmd.callback()
fmt.Printf("Pokedex > ")
}
}