feat: uncomment and implemented loadgist

pull/1342/head
davidzagi93@gmail.com 3 years ago
parent 434ba2854e
commit b7bfc44830
  1. 2
      libs/remix-ui/terminal/src/lib/commands.ts
  2. 8
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -9,7 +9,7 @@ export const allCommands = [
// { 'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.' }, // { '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.exeCurrent()': 'Run the script currently displayed in the editor.' },
// { 'remix.help()': 'Display this help message.' }, // { 'remix.help()': 'Display this help message.' },
// { 'remix.loadgist(id)': 'Load a gist in the file explorer.' }, { '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.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm or ipfs.' },
// { 'swarmgw.get(url, cb)': 'Download files from Swarm via https://swarm-gateways.net/' }, // { 'swarmgw.get(url, cb)': 'Download files from Swarm via https://swarm-gateways.net/' },

@ -169,6 +169,12 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
return '' return ''
} }
function loadgist (id, cb) {
console.log('load gist')
props.gistHandler.loadFromGist({ gist: id }, props._deps.fileManager)
if (cb) cb()
}
const _shell = async (script, scopedCommands, done) => { // default shell const _shell = async (script, scopedCommands, done) => { // default shell
if (script.indexOf('remix:') === 0) { if (script.indexOf('remix:') === 0) {
return done(null, 'This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.') return done(null, 'This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.')
@ -176,7 +182,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
if (script.indexOf('remix.') === 0) { if (script.indexOf('remix.') === 0) {
// we keep the old feature. This will basically only be called when the command is querying the "remix" object. // we keep the old feature. This will basically only be called when the command is querying the "remix" object.
// for all the other case, we use the Code Executor plugin // for all the other case, we use the Code Executor plugin
const context = { remix: { exeCurrent: () => { return execute(undefined, undefined) } } } const context = { remix: { exeCurrent: () => { return execute(undefined, undefined) }, loadgist: () => { return loadgist(script, undefined) } } }
try { try {
const cmds = vm.createContext(context) const cmds = vm.createContext(context)
const result = vm.runInContext(script, cmds) const result = vm.runInContext(script, cmds)

Loading…
Cancel
Save