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,
|
__("Welcome to Embark") + " " + this.version,
|
||||||
"",
|
"",
|
||||||
__("possible commands are:"),
|
__("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!
|
// TODO: only if the blockchain is actually active!
|
||||||
// will need to pass te current embark state here
|
// will need to pass te current embark state here
|
||||||
"ipfs - " + __("instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)"),
|
"ipfs - " + __("instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)"),
|
||||||
|
@ -205,12 +203,13 @@ class Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerConsoleCommands() {
|
private registerConsoleCommands() {
|
||||||
this.embark.registerConsoleCommand((cmd: string, options?: any) => {
|
this.embark.registerConsoleCommand({
|
||||||
const [cmdName, length] = cmd.split(" ");
|
description: __("display console commands history"),
|
||||||
return {
|
matches: ["history"],
|
||||||
match: () => cmdName === "history",
|
use: "history <optionalLength>",
|
||||||
process: (callback: any) => this.getHistory(length, callback),
|
}, (cmd: string, callback: any) => {
|
||||||
};
|
const [_cmdName, length] = cmd.split(" ");
|
||||||
|
this.getHistory(length, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,28 +89,41 @@ class ENS {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerConsoleCommands() {
|
registerConsoleCommands() {
|
||||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
this.embark.registerConsoleCommand({
|
||||||
let [cmdName, domain] = cmd.split(' ');
|
use: 'resolve <name>',
|
||||||
return {
|
description: __('Resolves an ENS name'),
|
||||||
match: () => cmdName === 'resolve',
|
matches: (cmd) => {
|
||||||
process: (cb) => global.EmbarkJS.Names.resolve(domain, cb)
|
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) => {
|
this.embark.registerConsoleCommand({
|
||||||
let [cmdName, address] = cmd.split(' ');
|
use: 'lookup <address>',
|
||||||
return {
|
description: __('Lookup an ENS address'),
|
||||||
match: () => cmdName === 'lookup',
|
matches: (cmd) => {
|
||||||
process: (cb) => global.EmbarkJS.Names.lookup(address, cb)
|
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(' ');
|
this.embark.registerConsoleCommand({
|
||||||
return {
|
use: 'registerSubDomain <subDomain>',
|
||||||
match: () => cmdName === 'registerSubDomain',
|
description: __('Register an ENS sub-domain'),
|
||||||
process: (cb) => global.EmbarkJS.Names.registerSubDomain(name, address, cb)
|
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() {
|
registerCommands() {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
const matches = ['versions'];
|
||||||
return {
|
if (__('versions') !== matches[0]) {
|
||||||
match: () => cmd === "versions" || cmd === __('versions'),
|
matches.push(__('versions'));
|
||||||
process: (callback) => {
|
}
|
||||||
|
this.embark.registerConsoleCommand({
|
||||||
|
matches,
|
||||||
|
description: __("display versions in use for libraries and tools like web3 and solc")
|
||||||
|
}, (cmd, callback) => {
|
||||||
let text = [__('versions in use') + ':'];
|
let text = [__('versions in use') + ':'];
|
||||||
for (let lib in self.versions) {
|
for (let lib in self.versions) {
|
||||||
text.push(lib + ": " + self.versions[lib]);
|
text.push(lib + ": " + self.versions[lib]);
|
||||||
}
|
}
|
||||||
callback(null, text.join('\n'));
|
callback(null, text.join('\n'));
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue