-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (63 loc) · 1.9 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
package main
import (
"fmt"
"os"
"github.com/alecthomas/kong"
"github.com/soonkuk/mitum-blocksign/cmds"
currencycmds "github.com/spikeekips/mitum-currency/cmds"
mitumcmds "github.com/spikeekips/mitum/launch/cmds"
"github.com/spikeekips/mitum/util"
)
var (
Version = "v0.0.0"
options = []kong.Option{
kong.Name("mitum-currency"),
kong.Description("mitum-currency tool"),
currencycmds.KeyAddressVars,
currencycmds.SendVars,
mitumcmds.BlockDownloadVars,
}
)
type mainflags struct {
Version VersionCommand `cmd:"" help:"version"`
Node cmds.NodeCommand `cmd:"" help:"node"`
Key currencycmds.KeyCommand `cmd:"" help:"key"`
Seal cmds.SealCommand `cmd:"" help:"seal"`
Storage currencycmds.StorageCommand `cmd:"" help:"storage"`
Deploy currencycmds.DeployCommand `cmd:"" help:"deploy"`
QuicClient mitumcmds.QuicClientCommand `cmd:"" help:"quic-client"`
}
func main() {
nodeCommand, err := cmds.NewNodeCommand()
if err != nil {
fmt.Fprintf(os.Stderr, "error: %+v\n", err) // revive:disable-line:unhandled-error
os.Exit(1)
}
flags := mainflags{
Node: nodeCommand,
Key: currencycmds.NewKeyCommand(),
Seal: cmds.NewSealCommand(),
Storage: currencycmds.NewStorageCommand(),
Deploy: currencycmds.NewDeployCommand(),
QuicClient: mitumcmds.NewQuicClientCommand(),
}
kctx, err := mitumcmds.Context(os.Args[1:], &flags, options...)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %+v\n", err) // revive:disable-line:unhandled-error
os.Exit(1)
}
version := util.Version(Version)
if err := version.IsValid(nil); err != nil {
kctx.FatalIfErrorf(err)
}
if err := kctx.Run(version); err != nil {
kctx.FatalIfErrorf(err)
}
os.Exit(0)
}
type VersionCommand struct{}
func (*VersionCommand) Run() error {
version := util.Version(Version)
_, _ = fmt.Fprintln(os.Stdout, version)
return nil
}