-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.go
43 lines (36 loc) · 937 Bytes
/
init.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
package cmds
import (
"context"
"os"
"github.com/ProtoconNet/mitum2/launch"
"github.com/ProtoconNet/mitum2/util/encoder"
)
var (
encs *encoder.Encoders
enc encoder.Encoder
)
func init() {
pctx := context.Background()
baseFlags := launch.BaseFlags{
LoggingFlags: launch.LoggingFlags{
Out: []launch.LogOutFlag{launch.LogOutFlag("stdout")},
Format: "terminal",
},
}
pctx = context.WithValue(pctx, launch.FlagsContextKey, baseFlags)
log, logout, err := launch.SetupLoggingFromFlags(baseFlags.LoggingFlags)
if err != nil {
panic(err)
}
pctx = context.WithValue(pctx, launch.LoggingContextKey, log) //revive:disable-line:modifies-parameter
pctx = context.WithValue(pctx, launch.LogOutContextKey, logout) //revive:disable-line:modifies-parameter
cmd := BaseCommand{
Out: os.Stdout,
}
if _, err := cmd.prepare(pctx); err != nil {
panic(err)
} else {
encs = cmd.Encoders
enc = cmd.Encoder
}
}