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
6403bca9
Commit
6403bca9
authored
Aug 07, 2018
by
Evgeniy Filatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented `execute` terminal command
parent
d35fe6f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
cmdInterpreterAPI.js
src/lib/cmdInterpreterAPI.js
+36
-4
No files found.
src/lib/cmdInterpreterAPI.js
View file @
6403bca9
...
...
@@ -17,6 +17,7 @@ class CmdInterpreterAPI {
self
.
_components
.
terminal
=
terminal
self
.
_deps
=
{
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
}
self
.
commandHelp
=
{
...
...
@@ -24,6 +25,7 @@ class CmdInterpreterAPI {
'remix.loadgist(id)'
:
'Load a gist in the file explorer.'
,
'remix.loadurl(url)'
:
'Load the given url in the file explorer. The url can be of type github, swarm or ipfs.'
,
'remix.setproviderurl(url)'
:
'Change the current provider to Web3 provider and set the url endpoint.'
,
'remix.execute(filepath)'
:
'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.'
,
'remix.exeCurrent()'
:
'Run the script currently displayed in the editor'
,
'remix.help()'
:
'Display this help message'
}
...
...
@@ -70,14 +72,44 @@ class CmdInterpreterAPI {
})
}
exeCurrent
(
cb
)
{
return
this
.
execute
(
undefined
,
cb
)
}
execute
(
file
,
cb
)
{
const
self
=
this
var
content
=
self
.
_deps
.
editor
.
currentContent
()
if
(
!
content
)
{
toolTip
(
'no content to execute'
)
function
_execute
(
content
,
cb
)
{
if
(
!
content
)
{
toolTip
(
'no content to execute'
)
if
(
cb
)
cb
()
return
}
self
.
_components
.
terminal
.
commands
.
script
(
content
)
}
if
(
typeof
file
===
'undefined'
)
{
var
content
=
self
.
_deps
.
editor
.
currentContent
()
_execute
(
content
,
cb
)
return
}
var
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
file
)
if
(
!
provider
)
{
toolTip
(
`provider for path
${
file
}
not found`
)
if
(
cb
)
cb
()
return
}
self
.
_components
.
terminal
.
commands
.
script
(
content
)
provider
.
get
(
file
,
(
error
,
content
)
=>
{
if
(
error
)
{
toolTip
(
error
)
if
(
cb
)
cb
()
return
}
_execute
(
content
,
cb
)
})
}
help
(
cb
)
{
const
self
=
this
...
...
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