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
96a751b1
Commit
96a751b1
authored
Sep 20, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmdInterpreter: debug, loadgist, loadswarm, setproviderurl
parent
ae90c173
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
28 deletions
+50
-28
app.js
src/app.js
+43
-13
terminal.js
src/app/panels/terminal.js
+1
-1
cmdInterpreter.js
src/lib/cmdInterpreter.js
+6
-14
No files found.
src/app.js
View file @
96a751b1
...
...
@@ -6,6 +6,7 @@ var yo = require('yo-yo')
var
async
=
require
(
'async'
)
var
remixLib
=
require
(
'remix-lib'
)
var
EventManager
=
remixLib
.
EventManager
var
swarmgw
=
require
(
'swarmgw'
)
var
UniversalDApp
=
require
(
'./universal-dapp.js'
)
var
UniversalDAppUI
=
require
(
'./universal-dapp-ui.js'
)
...
...
@@ -351,6 +352,42 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
})
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
)
=>
{
startdebugging
(
hash
)
})
cmdInterpreter
.
event
.
register
(
'loadgist'
,
(
id
)
=>
{
loadFromGist
({
gist
:
id
})
})
cmdInterpreter
.
event
.
register
(
'loadswarm'
,
(
url
)
=>
{
swarmgw
.
get
(
url
,
function
(
err
,
ret
)
{
if
(
err
)
{
modalDialogCustom
.
log
(
`Unable to load
${
url
}
from swarm:
${
err
}
`
)
}
else
{
ret
=
JSON
.
parse
(
ret
)
for
(
var
k
in
ret
.
sources
)
{
var
url
=
ret
.
sources
[
k
].
urls
[
0
]
// @TODO retrieve all other content
swarmgw
.
get
(
url
,
(
error
,
content
)
=>
{
if
(
!
error
)
{
filesProviders
[
'browser'
].
addReadOnly
(
k
,
content
)
}
else
{
filesProviders
[
'browser'
].
addReadOnly
(
k
,
`Cannot retrieve the content of
${
url
}
:
${
error
}
`
)
}
})
}
}
})
})
cmdInterpreter
.
event
.
register
(
'setproviderurl'
,
(
url
)
=>
{
executionContext
.
setContext
(
'web3'
,
url
,
true
)
})
// ----------------- editor ----------------------------
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
...
...
@@ -436,6 +473,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- editor panel ----------------------
this
.
_components
.
editorpanel
=
new
EditorPanel
({
api
:
{
cmdInterpreter
:
cmdInterpreter
,
editor
:
self
.
_components
.
editor
,
config
:
self
.
_api
.
config
,
txListener
:
txlistener
,
...
...
@@ -503,8 +541,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
// ------------------ gist load ----------------
var
loadingFromGist
=
gistHandler
.
handleLoad
(
queryParams
.
get
()
,
function
(
gistId
)
{
function
loadFromGist
(
gistId
)
{
return
gistHandler
.
handleLoad
(
gistId
,
function
(
gistId
)
{
$
.
ajax
({
url
:
'https://api.github.com/gists/'
+
gistId
,
jsonp
:
'callback'
,
...
...
@@ -520,6 +558,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
})
})
}
var
loadingFromGist
=
loadFromGist
(
queryParams
.
get
())
// insert ballot contract if there are no files available
if
(
!
loadingFromGist
)
{
...
...
@@ -608,21 +649,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
var
staticanalysis
=
new
StaticAnalysis
(
staticAnalysisAPI
,
compiler
.
event
)
// ----------------- Command Interpreter -----------------
/*
this module basically listen on user input (from terminal && editor)
and interpret them as command
*/
var
cmdInterpreter
=
new
CommandInterpreter
()
cmdInterpreter
.
event
.
register
(
'debug'
,
(
hash
)
=>
{
startdebugging
(
hash
)
})
// ---------------- Righthand-panel --------------------
var
rhpAPI
=
{
config
:
config
,
cmdInterpreter
:
cmdInterpreter
,
setEditorSize
(
delta
)
{
$
(
'#righthand-panel'
).
css
(
'width'
,
delta
)
self
.
_view
.
centerpanel
.
style
.
right
=
delta
+
'px'
...
...
src/app/panels/terminal.js
View file @
96a751b1
...
...
@@ -71,8 +71,8 @@ class Terminal {
self
.
registerCommand
(
'error'
,
self
.
_blocksRenderer
(
'error'
),
{
activate
:
true
})
self
.
registerCommand
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
var
script
=
String
(
args
[
0
])
if
(
self
.
_api
.
cmdInterpreter
&&
self
.
_api
.
cmdInterpreter
.
interpret
(
script
))
return
scopedCommands
.
log
(
`>
${
script
}
`
)
if
(
self
.
_api
.
cmdInterpreter
&&
self
.
_api
.
cmdInterpreter
.
interpret
(
script
))
return
self
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
if
(
error
)
scopedCommands
.
error
(
error
)
else
scopedCommands
.
log
(
output
)
...
...
src/lib/cmdInterpreter.js
View file @
96a751b1
...
...
@@ -8,23 +8,15 @@ class CmdInterpreter {
}
interpret
(
cmd
)
{
if
(
!
cmd
)
return
false
for
(
var
c
in
commands
)
{
if
(
commands
[
c
].
exec
(
cmd
)
)
{
commands
[
c
].
action
(
this
,
cmd
)
return
true
var
accept
=
commandsRegEx
.
exec
(
cmd
)
if
(
accept
)
{
this
.
event
.
trigger
(
accept
[
1
],
[
cmd
.
replace
(
commandsRegEx
,
''
)]
)
return
accept
[
1
]
}
}
return
false
return
null
}
}
var
commands
=
[
{
command
:
/^debug /
,
action
:
(
self
,
command
)
=>
{
self
.
event
.
trigger
(
'debug'
,
command
.
replace
(
'debug '
,
''
))
}
}
]
var
commandsRegEx
=
/^remix:
(
debug|loadgist|setproviderurl|loadswarm
)\s
/
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