Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
0f032a54
Unverified
Commit
0f032a54
authored
Feb 28, 2018
by
yann300
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #806 from ethereum/startDebug
[WIP] add command interpreter in the console
parents
3396f0ac
c2700c22
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
14 deletions
+113
-14
app.js
src/app.js
+84
-14
editor-panel.js
src/app/panels/editor-panel.js
+1
-0
terminal.js
src/app/panels/terminal.js
+1
-0
run-tab.js
src/app/tabs/run-tab.js
+3
-0
cmdInterpreter.js
src/lib/cmdInterpreter.js
+24
-0
No files found.
src/app.js
View file @
0f032a54
...
@@ -41,6 +41,7 @@ var ContextualListener = require('./app/editor/contextualListener')
...
@@ -41,6 +41,7 @@ var ContextualListener = require('./app/editor/contextualListener')
var
ContextView
=
require
(
'./app/editor/contextView'
)
var
ContextView
=
require
(
'./app/editor/contextView'
)
var
BasicReadOnlyExplorer
=
require
(
'./app/files/basicReadOnlyExplorer'
)
var
BasicReadOnlyExplorer
=
require
(
'./app/files/basicReadOnlyExplorer'
)
var
toolTip
=
require
(
'./app/ui/tooltip'
)
var
toolTip
=
require
(
'./app/ui/tooltip'
)
var
CommandInterpreter
=
require
(
'./lib/cmdInterpreter'
)
var
styleGuide
=
remixLib
.
ui
.
themeChooser
var
styleGuide
=
remixLib
.
ui
.
themeChooser
var
styles
=
styleGuide
.
chooser
()
var
styles
=
styleGuide
.
chooser
()
...
@@ -354,6 +355,71 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -354,6 +355,71 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
})
})
txlistener
.
startListening
()
txlistener
.
startListening
()
// ----------------- Command Interpreter -----------------
/*
this module basically listen on user input (from terminal && editor)
and interpret them as commands
*/
var
cmdInterpreter
=
new
CommandInterpreter
()
cmdInterpreter
.
event
.
register
(
'debug'
,
(
hash
,
cb
)
=>
{
startdebugging
(
hash
)
if
(
cb
)
cb
()
})
cmdInterpreter
.
event
.
register
(
'loadgist'
,
(
id
,
cb
)
=>
{
loadFromGist
({
gist
:
id
})
if
(
cb
)
cb
()
})
cmdInterpreter
.
event
.
register
(
'loadurl'
,
(
url
,
cb
)
=>
{
importExternal
(
url
,
(
err
,
content
)
=>
{
if
(
err
)
{
toolTip
(
`Unable to load
${
url
}
from swarm:
${
err
}
`
)
if
(
cb
)
cb
(
err
)
}
else
{
try
{
content
=
JSON
.
parse
(
content
)
async
.
eachOfSeries
(
content
.
sources
,
(
value
,
file
,
callbackSource
)
=>
{
var
url
=
value
.
urls
[
0
]
// @TODO retrieve all other contents ?
importExternal
(
url
,
(
error
,
content
)
=>
{
if
(
error
)
{
toolTip
(
`Cannot retrieve the content of
${
url
}
:
${
error
}
`
)
}
callbackSource
()
})
},
(
error
)
=>
{
if
(
cb
)
cb
(
error
)
})
}
catch
(
e
)
{}
if
(
cb
)
cb
()
}
})
})
cmdInterpreter
.
event
.
register
(
'setproviderurl'
,
(
url
,
cb
)
=>
{
executionContext
.
setProviderFromEndpoint
(
url
,
'web3'
,
(
error
)
=>
{
if
(
error
)
toolTip
(
error
)
if
(
cb
)
cb
()
})
})
cmdInterpreter
.
event
.
register
(
'batch'
,
(
url
,
cb
)
=>
{
var
content
=
editor
.
get
(
editor
.
current
())
if
(
!
content
)
{
toolTip
(
'no content to execute'
)
if
(
cb
)
cb
()
return
}
var
split
=
content
.
split
(
'
\
n'
)
async
.
eachSeries
(
split
,
(
value
,
cb
)
=>
{
if
(
!
cmdInterpreter
.
interpret
(
value
,
(
error
)
=>
{
error
?
cb
(
`Cannot run
${
value
}
. stopping`
)
:
cb
()
}))
{
cb
(
`Cannot interpret
${
value
}
. stopping`
)
}
},
(
error
)
=>
{
if
(
error
)
toolTip
(
error
)
if
(
cb
)
cb
()
})
})
// ----------------- editor ----------------------------
// ----------------- editor ----------------------------
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
...
@@ -439,6 +505,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -439,6 +505,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- editor panel ----------------------
// ----------------- editor panel ----------------------
this
.
_components
.
editorpanel
=
new
EditorPanel
({
this
.
_components
.
editorpanel
=
new
EditorPanel
({
api
:
{
api
:
{
cmdInterpreter
:
cmdInterpreter
,
editor
:
self
.
_components
.
editor
,
editor
:
self
.
_components
.
editor
,
config
:
self
.
_api
.
config
,
config
:
self
.
_api
.
config
,
txListener
:
txlistener
,
txListener
:
txlistener
,
...
@@ -506,23 +573,26 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -506,23 +573,26 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
}
// ------------------ gist load ----------------
// ------------------ gist load ----------------
function
loadFromGist
(
gistId
)
{
var
loadingFromGist
=
gistHandler
.
handleLoad
(
queryParams
.
get
(),
function
(
gistId
)
{
return
gistHandler
.
handleLoad
(
gistId
,
function
(
gistId
)
{
$
.
ajax
({
$
.
ajax
({
url
:
'https://api.github.com/gists/'
+
gistId
,
url
:
'https://api.github.com/gists/'
+
gistId
,
jsonp
:
'callback'
,
jsonp
:
'callback'
,
dataType
:
'jsonp'
,
dataType
:
'jsonp'
,
success
:
function
(
response
)
{
success
:
function
(
response
)
{
if
(
response
.
data
)
{
if
(
response
.
data
)
{
if
(
!
response
.
data
.
files
)
{
if
(
!
response
.
data
.
files
)
{
modalDialogCustom
.
alert
(
'Gist load error: '
+
response
.
data
.
message
)
modalDialogCustom
.
alert
(
'Gist load error: '
+
response
.
data
.
message
)
return
return
}
loadFiles
(
response
.
data
.
files
,
'gist'
)
}
}
loadFiles
(
response
.
data
.
files
,
'gist'
)
}
}
}
}
)
})
})
})
}
var
loadingFromGist
=
loadFromGist
(
queryParams
.
get
())
// insert ballot contract if there are no files available
// insert ballot contract if there are no files available
if
(
!
loadingFromGist
)
{
if
(
!
loadingFromGist
)
{
...
...
src/app/panels/editor-panel.js
View file @
0f032a54
...
@@ -27,6 +27,7 @@ class EditorPanel {
...
@@ -27,6 +27,7 @@ class EditorPanel {
editor
:
opts
.
api
.
editor
,
// @TODO: instantiate in eventpanel instead of passing via `opts`
editor
:
opts
.
api
.
editor
,
// @TODO: instantiate in eventpanel instead of passing via `opts`
terminal
:
new
Terminal
({
terminal
:
new
Terminal
({
api
:
{
api
:
{
cmdInterpreter
:
self
.
_api
.
cmdInterpreter
,
getPosition
(
event
)
{
getPosition
(
event
)
{
var
limitUp
=
36
var
limitUp
=
36
var
limitDown
=
20
var
limitDown
=
20
...
...
src/app/panels/terminal.js
View file @
0f032a54
...
@@ -72,6 +72,7 @@ class Terminal {
...
@@ -72,6 +72,7 @@ class Terminal {
self
.
registerCommand
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
self
.
registerCommand
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
var
script
=
String
(
args
[
0
])
var
script
=
String
(
args
[
0
])
scopedCommands
.
log
(
`>
${
script
}
`
)
scopedCommands
.
log
(
`>
${
script
}
`
)
if
(
self
.
_api
.
cmdInterpreter
&&
self
.
_api
.
cmdInterpreter
.
interpret
(
script
))
return
self
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
self
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
if
(
error
)
scopedCommands
.
error
(
error
)
if
(
error
)
scopedCommands
.
error
(
error
)
else
scopedCommands
.
log
(
output
)
else
scopedCommands
.
log
(
output
)
...
...
src/app/tabs/run-tab.js
View file @
0f032a54
...
@@ -85,6 +85,9 @@ function runTab (container, appAPI, appEvents) {
...
@@ -85,6 +85,9 @@ function runTab (container, appAPI, appEvents) {
},
setFinalContext
)
},
setFinalContext
)
})
})
selectExEnv
.
value
=
executionContext
.
getProvider
()
selectExEnv
.
value
=
executionContext
.
getProvider
()
executionContext
.
event
.
register
(
'contextChanged'
,
(
context
,
silent
)
=>
{
setFinalContext
()
})
fillAccountsList
(
appAPI
,
el
)
fillAccountsList
(
appAPI
,
el
)
setInterval
(()
=>
{
setInterval
(()
=>
{
updateAccountBalances
(
container
,
appAPI
)
updateAccountBalances
(
container
,
appAPI
)
...
...
src/lib/cmdInterpreter.js
0 → 100644
View file @
0f032a54
'use strict'
var
remixLib
=
require
(
'remix-lib'
)
var
EventManager
=
remixLib
.
EventManager
class
CmdInterpreter
{
constructor
()
{
this
.
event
=
new
EventManager
()
}
interpret
(
cmd
)
{
if
(
!
cmd
)
return
false
var
accept
=
commandsRegEx
.
exec
(
cmd
)
if
(
accept
)
{
var
param
=
accept
[
2
]
if
(
param
)
param
=
param
.
trim
()
this
.
event
.
trigger
(
accept
[
1
],
[
param
])
return
accept
[
1
]
}
return
null
}
}
var
commandsRegEx
=
/^remix:
(
debug|loadgist|setproviderurl|loadurl|batch
)(
.*
)
/
module
.
exports
=
CmdInterpreter
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