mirror of https://github.com/embarklabs/embark.git
refactor: change some console commands to the new api
- history - ens functions - versions
This commit is contained in:
parent
3229e15841
commit
983921e917
|
@ -78,8 +78,6 @@ class Console {
|
|||
__("Welcome to Embark") + " " + this.version,
|
||||
"",
|
||||
__("possible commands are:"),
|
||||
"versions - " + __("display versions in use for libraries and tools like web3 and solc"),
|
||||
"history - " + __("display console commands history"),
|
||||
// TODO: only if the blockchain is actually active!
|
||||
// will need to pass te current embark state here
|
||||
"ipfs - " + __("instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)"),
|
||||
|
@ -205,12 +203,13 @@ class Console {
|
|||
}
|
||||
|
||||
private registerConsoleCommands() {
|
||||
this.embark.registerConsoleCommand((cmd: string, options?: any) => {
|
||||
const [cmdName, length] = cmd.split(" ");
|
||||
return {
|
||||
match: () => cmdName === "history",
|
||||
process: (callback: any) => this.getHistory(length, callback),
|
||||
};
|
||||
this.embark.registerConsoleCommand({
|
||||
description: __("display console commands history"),
|
||||
matches: ["history"],
|
||||
use: "history <optionalLength>",
|
||||
}, (cmd: string, callback: any) => {
|
||||
const [_cmdName, length] = cmd.split(" ");
|
||||
this.getHistory(length, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -89,28 +89,41 @@ class ENS {
|
|||
}
|
||||
|
||||
registerConsoleCommands() {
|
||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
||||
let [cmdName, domain] = cmd.split(' ');
|
||||
return {
|
||||
match: () => cmdName === 'resolve',
|
||||
process: (cb) => global.EmbarkJS.Names.resolve(domain, cb)
|
||||
};
|
||||
this.embark.registerConsoleCommand({
|
||||
use: 'resolve <name>',
|
||||
description: __('Resolves an ENS name'),
|
||||
matches: (cmd) => {
|
||||
let [cmdName] = cmd.split(' ');
|
||||
return cmdName === 'resolve';
|
||||
}
|
||||
}, (cmd, cb) => {
|
||||
let [_cmdName, domain] = cmd.split(' ');
|
||||
global.EmbarkJS.Names.resolve(domain, cb);
|
||||
});
|
||||
|
||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
||||
let [cmdName, address] = cmd.split(' ');
|
||||
return {
|
||||
match: () => cmdName === 'lookup',
|
||||
process: (cb) => global.EmbarkJS.Names.lookup(address, cb)
|
||||
};
|
||||
this.embark.registerConsoleCommand({
|
||||
use: 'lookup <address>',
|
||||
description: __('Lookup an ENS address'),
|
||||
matches: (cmd) => {
|
||||
let [cmdName] = cmd.split(' ');
|
||||
return cmdName === 'lookup';
|
||||
}
|
||||
}, (cmd, cb) => {
|
||||
let [_cmdName, address] = cmd.split(' ');
|
||||
global.EmbarkJS.Names.lookup(address, cb);
|
||||
});
|
||||
|
||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
||||
let [cmdName, name, address] = cmd.split(' ');
|
||||
return {
|
||||
match: () => cmdName === 'registerSubDomain',
|
||||
process: (cb) => global.EmbarkJS.Names.registerSubDomain(name, address, cb)
|
||||
};
|
||||
|
||||
this.embark.registerConsoleCommand({
|
||||
use: 'registerSubDomain <subDomain>',
|
||||
description: __('Register an ENS sub-domain'),
|
||||
matches: (cmd) => {
|
||||
let [cmdName] = cmd.split(' ');
|
||||
return cmdName === 'registerSubDomain';
|
||||
}
|
||||
}, (cmd, cb) => {
|
||||
let [_cmdName, name, address] = cmd.split(' ');
|
||||
global.EmbarkJS.Names.registerSubDomain(name, address, cb);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -39,17 +39,19 @@ class LibraryManager {
|
|||
|
||||
registerCommands() {
|
||||
const self = this;
|
||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
||||
return {
|
||||
match: () => cmd === "versions" || cmd === __('versions'),
|
||||
process: (callback) => {
|
||||
const matches = ['versions'];
|
||||
if (__('versions') !== matches[0]) {
|
||||
matches.push(__('versions'));
|
||||
}
|
||||
this.embark.registerConsoleCommand({
|
||||
matches,
|
||||
description: __("display versions in use for libraries and tools like web3 and solc")
|
||||
}, (cmd, callback) => {
|
||||
let text = [__('versions in use') + ':'];
|
||||
for (let lib in self.versions) {
|
||||
text.push(lib + ": " + self.versions[lib]);
|
||||
}
|
||||
callback(null, text.join('\n'));
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue