diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-09-25 19:08:48 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-09-25 19:08:48 +0800 |
commit | 8636f0e1c326c88bee636cc269da660e954b96b1 (patch) | |
tree | 481ed4fd4a7192cfc663415f01bc73649630a6fa /cmd/geth | |
parent | 69d86442a52fef131827771ee5fb0f2c0c24c97c (diff) | |
download | go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar.gz go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar.bz2 go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar.lz go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar.xz go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.tar.zst go-tangerine-8636f0e1c326c88bee636cc269da660e954b96b1.zip |
console/history respect datadir
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/js.go | 17 | ||||
-rw-r--r-- | cmd/geth/main.go | 1 |
2 files changed, 7 insertions, 11 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 3e3600705..b5ec82b57 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -145,7 +145,7 @@ func apiWordCompleter(line string, pos int) (head string, completions []string, return begin, completionWords, end } -func newLightweightJSRE(libPath string, client comms.EthereumClient, interactive bool) *jsre { +func newLightweightJSRE(libPath string, client comms.EthereumClient, datadir string, interactive bool) *jsre { js := &jsre{ps1: "> "} js.wait = make(chan *big.Int) js.client = client @@ -161,14 +161,14 @@ func newLightweightJSRE(libPath string, client comms.EthereumClient, interactive js.prompter = dumbterm{bufio.NewReader(os.Stdin)} } else { lr := liner.NewLiner() - js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) }) + js.withHistory(datadir, func(hist *os.File) { lr.ReadHistory(hist) }) lr.SetCtrlCAborts(true) js.loadAutoCompletion() lr.SetWordCompleter(apiWordCompleter) lr.SetTabCompletionStyle(liner.TabPrints) js.prompter = lr js.atexit = func() { - js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) + js.withHistory(datadir, func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) lr.Close() close(js.wait) } @@ -203,14 +203,14 @@ func newJSRE(ethereum *eth.Ethereum, libPath, corsDomain string, client comms.Et js.prompter = dumbterm{bufio.NewReader(os.Stdin)} } else { lr := liner.NewLiner() - js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) }) + js.withHistory(ethereum.DataDir, func(hist *os.File) { lr.ReadHistory(hist) }) lr.SetCtrlCAborts(true) js.loadAutoCompletion() lr.SetWordCompleter(apiWordCompleter) lr.SetTabCompletionStyle(liner.TabPrints) js.prompter = lr js.atexit = func() { - js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) + js.withHistory(ethereum.DataDir, func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) lr.Close() close(js.wait) } @@ -433,12 +433,7 @@ func hidepassword(input string) string { } } -func (self *jsre) withHistory(op func(*os.File)) { - datadir := common.DefaultDataDir() - if self.ethereum != nil { - datadir = self.ethereum.DataDir - } - +func (self *jsre) withHistory(datadir string, op func(*os.File)) { hist, err := os.OpenFile(filepath.Join(datadir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm) if err != nil { fmt.Printf("unable to open history file: %v\n", err) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index daffda30c..a9766b7f7 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -429,6 +429,7 @@ func attach(ctx *cli.Context) { repl := newLightweightJSRE( ctx.GlobalString(utils.JSpathFlag.Name), client, + ctx.GlobalString(utils.DataDirFlag.Name), true, ) |