cmd/ethereum: fix JS REPL exit and add support for dumb terminals

It is now possible to exit the REPL using Ctrl-C, Ctrl-D or by typing "exit".
This commit is contained in:
Felix Lange
2015-03-06 12:18:44 +01:00
parent 2393de5d6b
commit de86403f33
2 changed files with 60 additions and 31 deletions

View File

@ -125,7 +125,6 @@ runtime will execute the file and exit.
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
defer logger.Flush()
utils.HandleInterrupt()
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
@ -134,6 +133,7 @@ func main() {
func run(ctx *cli.Context) {
fmt.Printf("Welcome to the FRONTIER\n")
utils.HandleInterrupt()
eth := utils.GetEthereum(ClientIdentifier, Version, ctx)
startEth(ctx, eth)
// this blocks the thread
@ -144,9 +144,8 @@ func runjs(ctx *cli.Context) {
eth := utils.GetEthereum(ClientIdentifier, Version, ctx)
startEth(ctx, eth)
if len(ctx.Args()) == 0 {
repl := newREPL(eth)
utils.RegisterInterrupt(func(os.Signal) { repl.Stop() })
repl.Start()
runREPL(eth)
eth.Stop()
eth.WaitForShutdown()
} else if len(ctx.Args()) == 1 {
execJsFile(eth, ctx.Args()[0])