github.com/igggame/nebulas-go@v2.1.0+incompatible/cmd/neb/consolecmd.go (about) 1 // Copyright (C) 2017 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // the go-nebulas library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 package main 20 21 import ( 22 "os" 23 24 "github.com/nebulasio/go-nebulas/cmd/console" 25 "github.com/urfave/cli" 26 ) 27 28 var ( 29 consoleCommand = cli.Command{ 30 Action: MergeFlags(consoleStart), 31 Name: "console", 32 Usage: "Start an interactive JavaScript console", 33 Category: "CONSOLE COMMANDS", 34 Description: ` 35 The Neb console is an interactive shell for the JavaScript runtime environment.`, 36 } 37 ) 38 39 func consoleStart(ctx *cli.Context) error { 40 neb, err := makeNeb(ctx) 41 if err != nil { 42 return err 43 } 44 45 console := console.New(console.Config{ 46 Prompter: console.Stdin, 47 PrompterCh: make(chan string), 48 Writer: os.Stdout, 49 Neb: neb, 50 }) 51 52 console.Setup() 53 console.Interactive() 54 defer console.Stop() 55 return nil 56 }