-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
68 lines (62 loc) · 1.32 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/urfave/cli.v1"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "greet"
app.Usage = "fight the loneliness!"
app.Action = func(c *cli.Context) error {
name := "Nefertiti"
if c.String("lang") == "spanish" {
fmt.Println("Hola", name)
} else {
fmt.Println("Hello", name)
}
return nil
}
flags := []cli.Flag{
cli.StringFlag{Name: "load"},
}
app.Commands = []cli.Command{
{
Name: "dump",
Aliases: []string{"d"},
Usage: "dump solr data source",
Flags: []cli.Flag{
cli.StringFlag{Name: "field, f"},
cli.StringFlag{Name: "index, i"},
cli.StringFlag{Name: "src, s"},
cli.StringFlag{Name: "target, t"},
cli.IntFlag{Name: "consumer, c"},
},
Action: func(c *cli.Context) error {
src := c.String("src")
target := c.String("target")
index := c.String("index")
field := c.String("field")
consumerCount := c.Int("consumer")
//Export(server, true, field)
Export2ES(consumerCount, src,
target, index, "doc", field)
return nil
},
},
{
Name: "add",
Aliases: []string{"a"},
Usage: "add a task to the list",
Action: func(c *cli.Context) error {
return nil
},
},
}
app.Flags = flags
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}