-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_map.go
33 lines (28 loc) · 866 Bytes
/
command_map.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
package main
import "fmt"
func commandMap(config *commandConfig) error {
locationResponse, err := config.PokemonClient.GetLocations(config.NextUrl)
if err != nil {
fmt.Printf("Got error while running 'map' command: %v\n", err)
return nil
}
config.NextUrl = &locationResponse.NextUrl
config.PrevUrl = &locationResponse.PrevUrl
for _, location := range locationResponse.Results {
fmt.Printf("%s\n", location.Name)
}
return nil
}
func commandMapPrev(config *commandConfig) error {
locationResponse, err := config.PokemonClient.GetLocations(config.PrevUrl)
if err != nil {
fmt.Printf("Got error while running 'mapb' command: %v\n", err)
return nil
}
config.NextUrl = &locationResponse.NextUrl
config.PrevUrl = &locationResponse.PrevUrl
for _, location := range locationResponse.Results {
fmt.Printf("%s\n", location.Name)
}
return nil
}