neo-go/cli/main.go

49 lines
1.2 KiB
Go
Raw Normal View History

2018-01-26 18:04:13 +00:00
package main
import (
"fmt"
"os"
"runtime"
2018-01-26 18:04:13 +00:00
"github.com/nspcc-dev/neo-go/cli/query"
"github.com/nspcc-dev/neo-go/cli/server"
"github.com/nspcc-dev/neo-go/cli/smartcontract"
2020-08-04 06:40:06 +00:00
"github.com/nspcc-dev/neo-go/cli/util"
"github.com/nspcc-dev/neo-go/cli/vm"
"github.com/nspcc-dev/neo-go/cli/wallet"
"github.com/nspcc-dev/neo-go/pkg/config"
"github.com/urfave/cli"
2018-01-26 18:04:13 +00:00
)
func main() {
ctl := newApp()
if err := ctl.Run(os.Args); err != nil {
panic(err)
}
}
func versionPrinter(c *cli.Context) {
_, _ = fmt.Fprintf(c.App.Writer, "NeoGo\nVersion: %s\nGoVersion: %s\n",
config.Version,
runtime.Version(),
)
}
func newApp() *cli.App {
cli.VersionPrinter = versionPrinter
ctl := cli.NewApp()
ctl.Name = "neo-go"
ctl.Version = config.Version
ctl.Usage = "Official Go client for Neo"
cli: set ctl.ErrWriter We did not have it set, however we use it in the several places which results with the following panic: ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4ddf0d] goroutine 1 [running]: fmt.Fprintln(0x0, 0x0, 0xc0001d7c08, 0x1, 0x1, 0x10376c0, 0xc0002051c0, 0x0) fmt/print.go:265 +0x5d github.com/nspcc-dev/neo-go/cli/wallet.transferNEP5(0xc0000a9080, 0x0, 0x0) github.com/nspcc-dev/neo-go/cli/wallet/nep5.go:445 +0x9eb github.com/urfave/cli.HandleAction(0xc837c0, 0xf26198, 0xc0000a9080, 0xc00007f600, 0x0) github.com/urfave/cli@v1.20.0/app.go:490 +0xc8 github.com/urfave/cli.Command.Run(0xdc66a3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdd0b0d, 0x14, 0xdf6c25, ...) github.com/urfave/cli@v1.20.0/command.go:210 +0x9e8 github.com/urfave/cli.(*App).RunAsSubcommand(0xc0001aa340, 0xc0000a8dc0, 0x0, 0x0) github.com/urfave/cli@v1.20.0/app.go:379 +0x88b github.com/urfave/cli.Command.startApp(0xdc23e4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdd546a, 0x18, 0x0, ...) github.com/urfave/cli@v1.20.0/command.go:298 +0x81a github.com/urfave/cli.Command.Run(0xdc23e4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0xdd546a, 0x18, 0x0, ...) github.com/urfave/cli@v1.20.0/command.go:98 +0x1219 github.com/urfave/cli.(*App).RunAsSubcommand(0xc0001aa1a0, 0xc0000a8c60, 0x0, 0x0) github.com/urfave/cli@v1.20.0/app.go:379 +0x88b github.com/urfave/cli.Command.startApp(0xdc45bf, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0xde1d28, 0x24, 0x0, ...) github.com/urfave/cli@v1.20.0/command.go:298 +0x81a github.com/urfave/cli.Command.Run(0xdc45bf, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0xde1d28, 0x24, 0x0, ...) github.com/urfave/cli@v1.20.0/command.go:98 +0x1219 github.com/urfave/cli.(*App).Run(0xc0001aa000, 0xc000030120, 0x12, 0x12, 0x0, 0x0) github.com/urfave/cli@v1.20.0/app.go:255 +0x741 main.main() command-line-arguments/main.go:18 +0x4b ```
2020-11-10 12:17:06 +00:00
ctl.ErrWriter = os.Stdout
2018-01-26 18:04:13 +00:00
ctl.Commands = append(ctl.Commands, server.NewCommands()...)
ctl.Commands = append(ctl.Commands, smartcontract.NewCommands()...)
ctl.Commands = append(ctl.Commands, wallet.NewCommands()...)
ctl.Commands = append(ctl.Commands, vm.NewCommands()...)
2020-08-04 06:40:06 +00:00
ctl.Commands = append(ctl.Commands, util.NewCommands()...)
ctl.Commands = append(ctl.Commands, query.NewCommands()...)
return ctl
2018-01-26 18:04:13 +00:00
}