Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
586198cc
Commit
586198cc
authored
Dec 08, 2017
by
Sorin Neacsu
Committed by
Felix Lange
Dec 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: add admin.clearHistory command (#15614)
parent
d95962cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
console.go
console/console.go
+11
-0
console_test.go
console/console_test.go
+1
-0
prompter.go
console/prompter.go
+8
-0
No files found.
console/console.go
View file @
586198cc
...
@@ -192,6 +192,7 @@ func (c *Console) init(preload []string) error {
...
@@ -192,6 +192,7 @@ func (c *Console) init(preload []string) error {
if
obj
:=
admin
.
Object
();
obj
!=
nil
{
// make sure the admin api is enabled over the interface
if
obj
:=
admin
.
Object
();
obj
!=
nil
{
// make sure the admin api is enabled over the interface
obj
.
Set
(
"sleepBlocks"
,
bridge
.
SleepBlocks
)
obj
.
Set
(
"sleepBlocks"
,
bridge
.
SleepBlocks
)
obj
.
Set
(
"sleep"
,
bridge
.
Sleep
)
obj
.
Set
(
"sleep"
,
bridge
.
Sleep
)
obj
.
Set
(
"clearHistory"
,
c
.
clearHistory
)
}
}
// Preload any JavaScript files before starting the console
// Preload any JavaScript files before starting the console
for
_
,
path
:=
range
preload
{
for
_
,
path
:=
range
preload
{
...
@@ -216,6 +217,16 @@ func (c *Console) init(preload []string) error {
...
@@ -216,6 +217,16 @@ func (c *Console) init(preload []string) error {
return
nil
return
nil
}
}
func
(
c
*
Console
)
clearHistory
()
{
c
.
history
=
nil
c
.
prompter
.
ClearHistory
()
if
err
:=
os
.
Remove
(
c
.
histPath
);
err
!=
nil
{
fmt
.
Fprintln
(
c
.
printer
,
"can't delete history file:"
,
err
)
}
else
{
fmt
.
Fprintln
(
c
.
printer
,
"history file deleted"
)
}
}
// consoleOutput is an override for the console.log and console.error methods to
// consoleOutput is an override for the console.log and console.error methods to
// stream the output into the configured output stream instead of stdout.
// stream the output into the configured output stream instead of stdout.
func
(
c
*
Console
)
consoleOutput
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
c
*
Console
)
consoleOutput
(
call
otto
.
FunctionCall
)
otto
.
Value
{
...
...
console/console_test.go
View file @
586198cc
...
@@ -68,6 +68,7 @@ func (p *hookedPrompter) PromptConfirm(prompt string) (bool, error) {
...
@@ -68,6 +68,7 @@ func (p *hookedPrompter) PromptConfirm(prompt string) (bool, error) {
}
}
func
(
p
*
hookedPrompter
)
SetHistory
(
history
[]
string
)
{}
func
(
p
*
hookedPrompter
)
SetHistory
(
history
[]
string
)
{}
func
(
p
*
hookedPrompter
)
AppendHistory
(
command
string
)
{}
func
(
p
*
hookedPrompter
)
AppendHistory
(
command
string
)
{}
func
(
p
*
hookedPrompter
)
ClearHistory
()
{}
func
(
p
*
hookedPrompter
)
SetWordCompleter
(
completer
WordCompleter
)
{}
func
(
p
*
hookedPrompter
)
SetWordCompleter
(
completer
WordCompleter
)
{}
// tester is a console test environment for the console tests to operate on.
// tester is a console test environment for the console tests to operate on.
...
...
console/prompter.go
View file @
586198cc
...
@@ -51,6 +51,9 @@ type UserPrompter interface {
...
@@ -51,6 +51,9 @@ type UserPrompter interface {
// if and only if the prompt to append was a valid command.
// if and only if the prompt to append was a valid command.
AppendHistory
(
command
string
)
AppendHistory
(
command
string
)
// ClearHistory clears the entire history
ClearHistory
()
// SetWordCompleter sets the completion function that the prompter will call to
// SetWordCompleter sets the completion function that the prompter will call to
// fetch completion candidates when the user presses tab.
// fetch completion candidates when the user presses tab.
SetWordCompleter
(
completer
WordCompleter
)
SetWordCompleter
(
completer
WordCompleter
)
...
@@ -158,6 +161,11 @@ func (p *terminalPrompter) AppendHistory(command string) {
...
@@ -158,6 +161,11 @@ func (p *terminalPrompter) AppendHistory(command string) {
p
.
State
.
AppendHistory
(
command
)
p
.
State
.
AppendHistory
(
command
)
}
}
// ClearHistory clears the entire history
func
(
p
*
terminalPrompter
)
ClearHistory
()
{
p
.
State
.
ClearHistory
()
}
// SetWordCompleter sets the completion function that the prompter will call to
// SetWordCompleter sets the completion function that the prompter will call to
// fetch completion candidates when the user presses tab.
// fetch completion candidates when the user presses tab.
func
(
p
*
terminalPrompter
)
SetWordCompleter
(
completer
WordCompleter
)
{
func
(
p
*
terminalPrompter
)
SetWordCompleter
(
completer
WordCompleter
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment