forked from hispertos/rep_V.11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (39 loc) · 952 Bytes
/
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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package main
import (
"errors"
"fmt"
"os"
"github.com/spf13/pflag"
"golang.org/x/term"
"github.com/ava-labs/avalanchego/app"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/version"
)
func main() {
fs := config.BuildFlagSet()
v, err := config.BuildViper(fs, os.Args[1:])
if errors.Is(err, pflag.ErrHelp) {
os.Exit(0)
}
if err != nil {
fmt.Printf("couldn't configure flags: %s\n", err)
os.Exit(1)
}
if v.GetBool(config.VersionKey) {
fmt.Print(version.String)
os.Exit(0)
}
nodeConfig, err := config.GetNodeConfig(v)
if err != nil {
fmt.Printf("couldn't load node config: %s\n", err)
os.Exit(1)
}
nodeApp := app.New(nodeConfig) // Create node wrapper
if term.IsTerminal(int(os.Stdout.Fd())) {
fmt.Println(app.Header)
}
exitCode := app.Run(nodeApp)
os.Exit(exitCode)
}