-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
main.go
48 lines (42 loc) · 1.54 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
package main
import (
"log"
"os"
"github.com/smartcontractkit/chainlink/core/cmd"
"github.com/smartcontractkit/chainlink/core/config"
"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/recovery"
)
func main() {
recovery.ReportPanics(func() {
Run(NewProductionClient(), os.Args...)
})
}
// Run runs the CLI, providing further command instructions by default.
func Run(client *cmd.Client, args ...string) {
app := cmd.NewApp(client)
client.Logger.ErrorIf(app.Run(args), "Error running app")
if err := client.CloseLogger(); err != nil {
log.Fatal(err)
}
}
// NewProductionClient configures an instance of the CLI to be used
// in production.
func NewProductionClient() *cmd.Client {
lggr, closeLggr := logger.NewLogger()
cfg := config.NewGeneralConfig(lggr)
prompter := cmd.NewTerminalPrompter()
return &cmd.Client{
Renderer: cmd.RendererTable{Writer: os.Stdout},
Config: cfg,
Logger: lggr,
CloseLogger: closeLggr,
AppFactory: cmd.ChainlinkAppFactory{},
KeyStoreAuthenticator: cmd.TerminalKeyStoreAuthenticator{Prompter: prompter},
FallbackAPIInitializer: cmd.NewPromptingAPIInitializer(prompter),
Runner: cmd.ChainlinkRunner{},
PromptingSessionRequestBuilder: cmd.NewPromptingSessionRequestBuilder(prompter),
ChangePasswordPrompter: cmd.NewChangePasswordPrompter(),
PasswordPrompter: cmd.NewPasswordPrompter(),
}
}