forked from nknorg/nkn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nknc.go
71 lines (65 loc) · 1.51 KB
/
nknc.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
package main
import (
"os"
"sort"
"syscall"
_ "github.com/nknorg/nkn/cli"
"github.com/nknorg/nkn/cli/asset"
. "github.com/nknorg/nkn/cli/common"
"github.com/nknorg/nkn/cli/debug"
"github.com/nknorg/nkn/cli/id"
"github.com/nknorg/nkn/cli/info"
"github.com/nknorg/nkn/cli/name"
"github.com/nknorg/nkn/cli/pruning"
"github.com/nknorg/nkn/cli/pubsub"
"github.com/nknorg/nkn/cli/service"
"github.com/nknorg/nkn/cli/wallet"
"github.com/nknorg/nnet/log"
"github.com/urfave/cli"
)
func Err2Errno(err error) int {
return 1 // TODO: github.com/nknorg/nkn/errno package.
}
func main() {
defer func() {
if r := recover(); r != nil {
log.Errorf("Panic: %+v", r)
os.Exit(1)
}
}()
app := cli.NewApp()
app.Name = "nknc"
app.Version = Version
app.HelpName = "nknc"
app.Usage = "command line tool for blockchain"
app.UsageText = "nknc [global options] command [command options] [args]"
app.HideHelp = false
app.HideVersion = false
//global options
app.Flags = []cli.Flag{
NewIpFlag(),
NewPortFlag(),
}
//commands
app.Commands = []cli.Command{
*debug.NewCommand(),
*info.NewCommand(),
*wallet.NewCommand(),
*asset.NewCommand(),
*name.NewCommand(),
*pubsub.NewCommand(),
*id.NewCommand(),
*pruning.NewCommand(),
*service.NewCommand(),
}
sort.Sort(cli.CommandsByName(app.Commands))
sort.Sort(cli.FlagsByName(app.Flags))
if err := app.Run(os.Args); err != nil {
switch err.(type) {
case syscall.Errno:
os.Exit(int(err.(syscall.Errno)))
default:
os.Exit(Err2Errno(err))
}
}
}