forked from smartcontractkit/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (46 loc) · 1.66 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
package core
import (
"fmt"
"log"
"os"
"github.com/Masterminds/semver/v3"
"github.com/smartcontractkit/chainlink/v2/core/build"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/recovery"
"github.com/smartcontractkit/chainlink/v2/core/static"
)
func init() {
// check version
if static.Version == static.Unset {
if !build.IsProd() {
return
}
log.Println(`Version was unset on production build. Chainlink should be built with static.Version set to a valid semver for production builds.`)
} else if _, err := semver.NewVersion(static.Version); err != nil {
panic(fmt.Sprintf("Version invalid: %q is not valid semver", static.Version))
}
}
func Main() (code int) {
recovery.ReportPanics(func() {
app := cmd.NewApp(newProductionClient())
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "Error running app: %v\n", err)
code = 1
}
})
return
}
// newProductionClient configures an instance of the CLI to be used in production.
func newProductionClient() *cmd.Shell {
prompter := cmd.NewTerminalPrompter()
return &cmd.Shell{
Renderer: cmd.RendererTable{Writer: os.Stdout},
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(),
}
}