mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
50 lines
830 B
Go
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
|
|
},
|
|
}
|
|
}
|