/
cmd.go
106 lines (102 loc) · 2.21 KB
/
cmd.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
"os"
"path/filepath"
"github.com/nimezhu/nbdata"
"github.com/urfave/cli/v2"
)
const (
//VERSION : Version of NucleServer
VERSION = "0.2.6"
//DIR : Default Directory for NucleServer
DIR = ".nucle"
)
func main() {
app := cli.NewApp()
app.Version = VERSION
app.Name = "Nucleome Data Server Tools"
app.Usage = "nucleserver start -i [[google_sheet_id OR xls file]] -p [[port]]"
app.EnableBashCompletion = true
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Usage: "Show more output",
},
}
home := nbdata.UserHomeDir()
root := filepath.Join(home, DIR)
app.Commands = []*cli.Command{
{
Name: "start",
Usage: "start a data server",
Action: CmdStart,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "input",
Aliases: []string{"i"},
Usage: "input data xls/google sheet id",
Value: "",
},
&cli.IntFlag{
Name: "port",
Aliases: []string{"p"},
Usage: "data server port",
Value: 8611,
},
&cli.StringFlag{
Name: "root",
Aliases: []string{"r"},
Usage: "root directory, default is $HOME/.nucle, in this directory store credentials and index files",
Value: root,
},
&cli.BoolFlag{
Name: "local",
Aliases: []string{"l"},
Usage: "serve 127.0.0.1 only",
},
&cli.StringFlag{
Name: "code",
Aliases: []string{"c"},
Usage: "set password for server, override -l",
Value: "",
},
&cli.StringFlag{
Name: "cors",
Usage: "add Customized CORS access",
Value: "",
},
},
},
{
Name: "file",
Usage: "start a file server",
Action: CmdFile,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "root", //TODO
Aliases: []string{"r"},
Usage: "root directory",
Value: home,
},
&cli.IntFlag{
Name: "port",
Aliases: []string{"p"},
Usage: "data server port",
Value: 8611,
},
&cli.StringFlag{
Name: "cors",
Usage: "add Customized CORS access",
Value: "",
},
},
},
{
Name: "update",
Usage: "update self to the latest version in GitHub release",
Action: CmdUpdate,
Flags: []cli.Flag{},
},
}
app.Run(os.Args)
}