go-ethereum/command/main.go
2021-10-04 09:48:12 +02:00

50 lines
830 B
Go

package main
import (
"fmt"
"os"
"github.com/ethereum/go-ethereum/command/server"
"github.com/mitchellh/cli"
)
func main() {
os.Exit(Run(os.Args[1:]))
}
func Run(args []string) int {
commands := commands()
cli := &cli.CLI{
Name: "bor",
Args: args,
Commands: commands,
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
func commands() map[string]cli.CommandFactory {
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
return map[string]cli.CommandFactory{
"server": func() (cli.Command, error) {
return &server.Command{
UI: ui,
}, nil
},
"version": func() (cli.Command, error) {
return &VersionCommand{
UI: ui,
}, nil
},
}
}