mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-18 10:16:30 +00:00
fix identation issues
This commit is contained in:
parent
24da141973
commit
f787e6be3c
@ -28,7 +28,7 @@ class Console {
|
|||||||
this.registerConsoleCommands();
|
this.registerConsoleCommands();
|
||||||
this.registerApi();
|
this.registerApi();
|
||||||
|
|
||||||
this.suggestions = new Suggestions(embark, options);
|
this.suggestions = new Suggestions(embark, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerApi() {
|
registerApi() {
|
||||||
|
@ -2,11 +2,11 @@ let utils = require('../../utils/utils');
|
|||||||
|
|
||||||
class Suggestions {
|
class Suggestions {
|
||||||
constructor(embark, options) {
|
constructor(embark, options) {
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.registerApi();
|
this.registerApi();
|
||||||
this.listenToEvents();
|
this.listenToEvents();
|
||||||
this.contracts = {}
|
this.contracts = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerApi() {
|
registerApi() {
|
||||||
@ -17,14 +17,14 @@ class Suggestions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
listenToEvents() {
|
listenToEvents() {
|
||||||
this.events.on("deploy:contract:deployed", (contract) => {
|
this.events.on("deploy:contract:deployed", (contract) => {
|
||||||
this.contracts[contract.className] = contract
|
this.contracts[contract.className] = contract
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getSuggestions(cmd) {
|
getSuggestions(cmd) {
|
||||||
cmd = cmd.toLowerCase()
|
cmd = cmd.toLowerCase()
|
||||||
|
|
||||||
if (cmd === 'web3' || cmd === 'web3.') {
|
if (cmd === 'web3' || cmd === 'web3.') {
|
||||||
return [
|
return [
|
||||||
@ -36,45 +36,45 @@ class Suggestions {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
let suggestions = []
|
let suggestions = []
|
||||||
for (let contractName in this.contracts) {
|
for (let contractName in this.contracts) {
|
||||||
let contract = this.contracts[contractName]
|
let contract = this.contracts[contractName]
|
||||||
if (contract.className.toLowerCase().indexOf(cmd) >= 0 || contract.deployedAddress.indexOf(cmd) >= 0 || cmd.indexOf('contract') >= 0) {
|
if (contract.className.toLowerCase().indexOf(cmd) >= 0 || contract.deployedAddress.indexOf(cmd) >= 0 || cmd.indexOf('contract') >= 0) {
|
||||||
suggestions.push({value: contract.className, command_type: "web3 object", description: "contract deployed at " + contract.deployedAddress});
|
suggestions.push({value: contract.className, command_type: "web3 object", description: "contract deployed at " + contract.deployedAddress});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('profile'.indexOf(cmd) >= 0) {
|
if ('profile'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: "profile " + contract.className, command_type: "embark command", description: "profile " + contract.className + " contract"});
|
suggestions.push({value: "profile " + contract.className, command_type: "embark command", description: "profile " + contract.className + " contract"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this registered through an API instead
|
// TODO: make this registered through an API instead
|
||||||
|
|
||||||
if ('help'.indexOf(cmd) >= 0) {
|
if ('help'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: 'help', command_type: "embark command", description: "displays quick list of some of the available embark commands"});
|
suggestions.push({value: 'help', command_type: "embark command", description: "displays quick list of some of the available embark commands"});
|
||||||
}
|
}
|
||||||
if ('versions'.indexOf(cmd) >= 0) {
|
if ('versions'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: 'versions', command_type: "embark command", description: "display versions in use for libraries and tools like web3 and solc"});
|
suggestions.push({value: 'versions', command_type: "embark command", description: "display versions in use for libraries and tools like web3 and solc"});
|
||||||
}
|
}
|
||||||
if ('ipfs'.indexOf(cmd) >= 0) {
|
if ('ipfs'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: 'ipfs', command_type: "javascript object", description: "instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)"});
|
suggestions.push({value: 'ipfs', command_type: "javascript object", description: "instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)"});
|
||||||
}
|
}
|
||||||
if ('swarm'.indexOf(cmd) >= 0) {
|
if ('swarm'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: 'swarm', command_type: "javascript object", description: "instantiated swarm-api object configured to the current environment (available if swarm is enabled)"});
|
suggestions.push({value: 'swarm', command_type: "javascript object", description: "instantiated swarm-api object configured to the current environment (available if swarm is enabled)"});
|
||||||
}
|
}
|
||||||
if (cmd == 'w' || cmd === 'we' || cmd === 'web') {
|
if (cmd == 'w' || cmd === 'we' || cmd === 'web') {
|
||||||
suggestions.push({value: 'web3', command_type: "javascript object", description: "instantiated web3.js object configured to the current environment"});
|
suggestions.push({value: 'web3', command_type: "javascript object", description: "instantiated web3.js object configured to the current environment"});
|
||||||
}
|
}
|
||||||
if ('embarkjs'.indexOf(cmd) >= 0) {
|
if ('embarkjs'.indexOf(cmd) >= 0) {
|
||||||
suggestions.push({value: 'EmbarkJS', command_type: "javascript object", description: "EmbarkJS static functions for Storage, Messages, Names, etc."});
|
suggestions.push({value: 'EmbarkJS', command_type: "javascript object", description: "EmbarkJS static functions for Storage, Messages, Names, etc."});
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort first the ones that match the command at the beginning of the string, then prefer smaller commands first
|
// sort first the ones that match the command at the beginning of the string, then prefer smaller commands first
|
||||||
return suggestions.sort((x,y) => {
|
return suggestions.sort((x,y) => {
|
||||||
let diff = x.value.indexOf(cmd) - y.value.indexOf(cmd)
|
let diff = x.value.indexOf(cmd) - y.value.indexOf(cmd)
|
||||||
if (diff !== 0) return diff;
|
if (diff !== 0) return diff;
|
||||||
return x.value.length - y.value.length;
|
return x.value.length - y.value.length;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user