-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathmain.go
91 lines (79 loc) · 1.59 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"log"
"os"
"fmt"
"path"
"time"
"github.com/keep-network/keep-core/cmd"
"github.com/urfave/cli"
)
const defaultConfigPath = "./config.toml"
var (
version string
revision string
configPath string
)
func main() {
if version == "" {
version = "unknown"
}
if revision == "" {
revision = "unknown"
}
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Usage = "CLI for The Keep Network"
app.Description = "Command line interface (CLI) for running a Keep provider"
app.Compiled = time.Now()
app.Authors = []cli.Author{
{
Name: "Keep Network",
Email: "info@keep.network",
},
}
app.Version = fmt.Sprintf("%s (revision %s)", version, revision)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config,c",
Value: defaultConfigPath,
Destination: &configPath,
Usage: "full path to the configuration file",
},
}
app.Commands = []cli.Command{
cmd.SmokeTestCommand,
cmd.StartCommand,
cmd.RelayCommand,
cmd.PingCommand,
{
Name: "print-info",
Usage: "Prints keep client information",
Action: func(c *cli.Context) error {
printInfo(c)
return nil
},
},
}
cli.AppHelpTemplate = fmt.Sprintf(`%s
ENVIRONMENT VARIABLES:
KEEP_ETHEREUM_PASSWORD keep client password
`, cli.AppHelpTemplate)
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func printInfo(c *cli.Context) {
fmt.Printf("Keep client: %s\n\n"+
"Description: %s\n"+
"version: %s\n"+
"revision: %s\n"+
"Config Path: %s\n",
c.App.Name,
c.App.Description,
version,
revision,
c.GlobalString("config"),
)
}