-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist.go
60 lines (46 loc) · 1.01 KB
/
list.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/evoL/gif/image"
"github.com/evoL/gif/store"
"os"
)
func ListCommand(c *cli.Context) {
s := getStore()
defer s.Close()
filter := listFilter(c)
images, err := s.List(filter)
if err != nil {
fmt.Println("Error while fetching: " + err.Error())
os.Exit(1)
}
fmt.Printf("%v images\n", len(images))
image.PrintAll(images)
}
func UrlCommand(c *cli.Context) {
s := getStore()
defer s.Close()
filter := orderAndLimit(store.RemoteFilter{Filter: typeFilter(c)}, c)
images, err := s.List(filter)
if err != nil {
fmt.Println("Error while fetching: " + err.Error())
os.Exit(1)
}
for _, image := range images {
fmt.Println(image.Url)
}
}
func PathCommand(c *cli.Context) {
s := getStore()
defer s.Close()
filter := orderAndLimit(typeFilter(c), c)
images, err := s.List(filter)
if err != nil {
fmt.Println("Error while fetching: " + err.Error())
os.Exit(1)
}
for _, image := range images {
fmt.Println(s.PathFor(&image))
}
}