2018-10-13 23:12:35 +00:00
let utils = require ( '../../utils/utils' ) ;
class Suggestions {
constructor ( _embark , options ) {
this . plugins = options . plugins ;
this . registerApi ( ) ;
}
registerApi ( ) {
let plugin = this . plugins . createPlugin ( 'consoleApi' , { } ) ;
plugin . registerAPICall ( 'post' , '/embark-api/suggestions' , ( req , res ) => {
let suggestions = this . getSuggestions ( req . body . command )
res . send ( { result : suggestions } )
} ) ;
}
getSuggestions ( cmd ) {
2018-10-14 03:27:20 +00:00
if ( cmd === 'web3' ) {
return [
{ value : 'web3.eth' , command _type : "web3 object" , description : "ethereum" } ,
{ value : 'web3.net' , command _type : "web3 object" , description : "network" } ,
{ value : 'web3.shh' , command _type : "web3 object" , description : "whisper" }
]
}
2018-10-13 23:12:35 +00:00
console . dir ( "printing suggestions for " + cmd ) ;
return [ { value : 'hello' , command _type : "embark" , description : "says hello back!" } , { value : 'SimpleStorage' , command _type : "web3 object" , description : "" } , { value : 'web3.eth.getAccounts' , command _type : "web3" , description : "get list of accounts" } ]
}
}
module . exports = Suggestions ;