/
main.go
60 lines (55 loc) · 1.21 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
package main
import (
"log"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "elasticsearch-fuse"
app.Version = "0.2.0"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "urls",
Value: "http://localhost:9200",
Usage: "Elasticsearch server URLs",
},
cli.StringFlag{
Name: "mount-path",
Value: "./elasticsearch-fuse",
Usage: "Directory path as mount point",
},
cli.IntFlag{
Name: "page",
Value: 10,
Usage: "The number of documents to list in one directory",
},
// TODO: updateInterval := flag.Int("update-interval", 10, "Interval seconds of same queries to Elasticsearch")
cli.BoolFlag{
Name: "debug",
Usage: "Emit debug logs",
},
}
app.Action = func(c *cli.Context) error {
// Get command options
urls := c.String("urls")
mountPath := c.String("mount")
pageSize := c.Int("page")
debug := c.Bool("debug")
// Create the filesystem is specialized for Elasticsearch
fs, err := NewElasticsearchFS(urls, pageSize, debug)
if err != nil {
return err
}
// Start the FUSE server
err = MountFilesystem(fs, mountPath)
if err != nil {
return err
}
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}