good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
fd1ddbce
Commit
fd1ddbce
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Save repl history to file and recall on next session
parent
a13aa873
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ethereum/repl.go
+26
-1
26 additions, 1 deletion
ethereum/repl.go
ethereum/repl_darwin.go
+3
-1
3 additions, 1 deletion
ethereum/repl_darwin.go
with
29 additions
and
2 deletions
ethereum/repl.go
+
26
−
1
View file @
fd1ddbce
package
main
package
main
import
(
import
(
"bufio"
"fmt"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/otto"
"github.com/obscuren/otto"
"io"
"os"
"path"
)
)
type
Repl
interface
{
type
Repl
interface
{
...
@@ -16,18 +21,38 @@ type JSRepl struct {
...
@@ -16,18 +21,38 @@ type JSRepl struct {
re
*
JSRE
re
*
JSRE
prompt
string
prompt
string
history
*
os
.
File
}
}
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
}
hist
,
err
:=
os
.
OpenFile
(
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"history"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
if
err
!=
nil
{
panic
(
err
)
}
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
,
history
:
hist
}
}
}
func
(
self
*
JSRepl
)
Start
()
{
func
(
self
*
JSRepl
)
Start
()
{
reader
:=
bufio
.
NewReader
(
self
.
history
)
for
{
line
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
&&
err
==
io
.
EOF
{
break
}
else
if
err
!=
nil
{
fmt
.
Println
(
"error reading history"
,
err
)
break
}
addHistory
(
line
[
:
len
(
line
)
-
1
])
}
self
.
read
()
self
.
read
()
}
}
func
(
self
*
JSRepl
)
Stop
()
{
func
(
self
*
JSRepl
)
Stop
()
{
self
.
re
.
Stop
()
self
.
re
.
Stop
()
self
.
history
.
Close
()
}
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
...
...
This diff is collapsed.
Click to expand it.
ethereum/repl_darwin.go
+
3
−
1
View file @
fd1ddbce
...
@@ -102,7 +102,9 @@ L:
...
@@ -102,7 +102,9 @@ L:
break
L
break
L
}
}
addHistory
(
str
[
:
len
(
str
)
-
1
])
//allow user to recall this line
hist
:=
str
[
:
len
(
str
)
-
1
]
addHistory
(
hist
)
//allow user to recall this line
self
.
history
.
WriteString
(
str
)
self
.
parseInput
(
str
)
self
.
parseInput
(
str
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment