-
Notifications
You must be signed in to change notification settings - Fork 5
/
servercmd.go
50 lines (48 loc) · 914 Bytes
/
servercmd.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
package main
import (
"github.com/urfave/cli/v2"
)
var (
nodeIdFlag = &cli.IntFlag{
Name: "id",
Usage: "id",
Required: true,
}
nodeSubCommand = &cli.Command{
Name: "node",
Usage: "start pbft node",
Description: "start pbft node",
ArgsUsage: "<id>",
Flags: []cli.Flag{
nodeIdFlag,
},
Action: func(c *cli.Context) error {
nodeId := c.Int("id")
server := NewServer(nodeId)
server.Start()
return nil
},
}
clientSubCommand = &cli.Command{
Name: "client",
Usage: "start pbft client",
Description: "start pbft client",
ArgsUsage: "",
Action: func(c *cli.Context) error {
client := NewClient()
client.Start()
return nil
},
}
PBFTCommand = &cli.Command{
Name: "pbft",
Usage: "pbft commands",
ArgsUsage: "",
Category: "pbft Commands",
Description: "",
Subcommands: []*cli.Command{
nodeSubCommand,
clientSubCommand,
},
}
)