Merge pull request #1269 from bas-vk/console-batch
added batch mode to console
This commit is contained in:
commit
ae36beb38f
@ -30,6 +30,7 @@ import (
|
||||
|
||||
"sort"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
"github.com/ethereum/go-ethereum/common/docserver"
|
||||
re "github.com/ethereum/go-ethereum/jsre"
|
||||
@ -329,7 +330,29 @@ func (self *jsre) welcome(ipcpath string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *jsre) interactive() {
|
||||
func (self *jsre) batch(args cli.Args) {
|
||||
statement := strings.Join(args, " ")
|
||||
val, err := self.re.Run(statement)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v", err)
|
||||
} else if val.IsDefined() && val.IsObject() {
|
||||
obj, _ := self.re.Get("ret_result")
|
||||
fmt.Printf("%v", obj)
|
||||
} else if val.IsDefined() {
|
||||
fmt.Printf("%v", val)
|
||||
}
|
||||
|
||||
if self.atexit != nil {
|
||||
self.atexit()
|
||||
}
|
||||
|
||||
self.re.Stop(false)
|
||||
}
|
||||
|
||||
func (self *jsre) interactive(ipcpath string) {
|
||||
self.welcome(ipcpath)
|
||||
|
||||
// Read input lines.
|
||||
prompt := make(chan string)
|
||||
inputln := make(chan string)
|
||||
|
@ -40,7 +40,7 @@ const (
|
||||
var (
|
||||
gitCommit string // set via linker flag
|
||||
nodeNameVersion string
|
||||
app = utils.NewApp(Version, "the ether console")
|
||||
app = utils.NewApp(Version, "the geth console")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -93,8 +93,11 @@ func main() {
|
||||
func run(ctx *cli.Context) {
|
||||
jspath := ctx.GlobalString(utils.JSpathFlag.Name)
|
||||
ipcpath := utils.IpcSocketPath(ctx)
|
||||
|
||||
repl := newJSRE(jspath, ipcpath)
|
||||
repl.welcome(ipcpath)
|
||||
repl.interactive()
|
||||
|
||||
if ctx.Args().Present() {
|
||||
repl.batch(ctx.Args())
|
||||
} else {
|
||||
repl.interactive(ipcpath)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user