-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
main.go
143 lines (136 loc) · 3.11 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package main
import (
"os"
"time"
"github.com/smartcontractkit/chainlink/cmd"
"github.com/smartcontractkit/chainlink/store"
"github.com/urfave/cli"
)
//go:generate sh -c "CGO_ENABLED=0 go run gui/main.go $PWD"
func init() {
time.LoadLocation("UTC")
}
func main() {
Run(NewProductionClient(), os.Args...)
}
// Run runs the CLI, providing further command instructions by default.
func Run(client *cmd.Client, args ...string) {
app := cli.NewApp()
app.Usage = "CLI for Chainlink"
app.Version = store.Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "json, j",
Usage: "json output as opposed to table",
},
}
app.Before = func(c *cli.Context) error {
if c.Bool("json") {
client.Renderer = cmd.RendererJSON{Writer: os.Stdout}
}
return nil
}
app.Commands = []cli.Command{
{
Name: "node",
Aliases: []string{"n"},
Flags: []cli.Flag{
cli.StringFlag{
Name: "password, p",
Usage: "text file holding the password for the node's account",
},
cli.BoolFlag{
Name: "debug, d",
Usage: "set logger level to debug",
},
},
Usage: "Run the chainlink node",
Action: client.RunNode,
},
{
Name: "account",
Aliases: []string{"a"},
Usage: "Display the account address with its ETH & LINK balances",
Action: client.DisplayAccountBalance,
},
{
Name: "jobspecs",
Aliases: []string{"jobs", "j", "specs"},
Usage: "Get all jobs",
Action: client.GetJobSpecs,
Flags: []cli.Flag{
cli.IntFlag{
Name: "page",
Usage: "page of results to display",
},
},
},
{
Name: "show",
Aliases: []string{"s"},
Usage: "Show a specific job",
Action: client.ShowJobSpec,
},
{
Name: "create",
Aliases: []string{"c"},
Usage: "Create job spec from JSON",
Action: client.CreateJobSpec,
},
{
Name: "run",
Aliases: []string{"r"},
Usage: "Begin job run for specid",
Action: client.CreateJobRun,
},
{
Name: "backup",
Usage: "Backup the database of the running node",
Action: client.BackupDatabase,
},
{
Name: "import",
Aliases: []string{"i"},
Usage: "Import a key file to use with the node",
Action: client.ImportKey,
},
{
Name: "bridge",
Usage: "Add a new bridge to the node",
Action: client.AddBridge,
},
{
Name: "getbridges",
Usage: "List all bridges added to the node",
Action: client.GetBridges,
Flags: []cli.Flag{
cli.IntFlag{
Name: "page",
Usage: "page of results to display",
},
},
},
{
Name: "showbridge",
Usage: "Show a specific bridge",
Action: client.ShowBridge,
},
{
Name: "removebridge",
Usage: "Removes a specific bridge",
Action: client.RemoveBridge,
},
}
app.Run(args)
}
// NewProductionClient configures an instance of the CLI to be used
// in production.
func NewProductionClient() *cmd.Client {
return &cmd.Client{
Renderer: cmd.RendererTable{Writer: os.Stdout},
Config: store.NewConfig(),
AppFactory: cmd.ChainlinkAppFactory{},
Auth: cmd.TerminalAuthenticator{Prompter: cmd.PasswordPrompter{}},
Runner: cmd.ChainlinkRunner{},
}
}