-
Notifications
You must be signed in to change notification settings - Fork 81
/
main.go
91 lines (76 loc) · 1.8 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
80
81
82
83
84
85
86
87
88
89
90
91
// Call the main execute from vendor/rust_src_easy/main_execute.rs
package main
import (
"fmt"
"os"
"github.com/bitconch/bus"
"github.com/bitconch/bus/gobin/utils"
"gopkg.in/urfave/cli.v1"
"github.com/pkg/profile"
)
var (
// IdentityFile stores users' keypair
IdentityFile string
// NetworkEntryPoint represent the network entry point
NetworkEntryPoint string
// LedgerLocation is the location of the ledger file
LedgerLocation string
gitCommit = ""
// add new App with description
app = utils.NewApp(gitCommit, "Bitconch chain fullnode CLI")
)
// Flags to be used in the cli
var (
identityFlag = cli.StringFlag{
Name: "identity,i",
Usage: "ID file location",
Destination: &IdentityFile,
}
networkFlag = cli.StringFlag{
Name: "network,n",
Usage: "Connect to the network entry point `HOST:PORT` ; defaults to 127.0.0.1:8001 ",
Destination: &NetworkEntryPoint,
}
ledgerFlag = cli.StringFlag{
Name: "ledger,l",
Usage: "Ledger file location",
Destination: &LedgerLocation,
}
)
//init define subcommand and flags linked to cli
func init() {
// clapcli is the action function
app.Action = fullnodeCli
// define the sub commands
app.Commands = []cli.Command{
//commandGenerate,
}
// define the flags
app.Flags = []cli.Flag{
identityFlag,
networkFlag,
ledgerFlag,
}
}
func main() {
defer profile.Start().Stop()
//bus.CallFullnode()
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func fullnodeCli(ctx *cli.Context) error {
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}
// handle the arguments
fmt.Println("Do some stuff")
// start the full node instance
bus.CallFullnode(
IdentityFile,
NetworkEntryPoint,
LedgerLocation,
)
return nil
}