refactor common geth command options into the a common method

This commit is contained in:
Iuri Matias 2016-10-30 20:08:45 -04:00
parent 0a2a26fd29
commit e58671e742

View File

@ -46,9 +46,9 @@ GethCommands.prototype.newAccountCommand = function() {
return cmd + "account new ";
};
GethCommands.prototype.listAccountsCommand = function() {
GethCommands.prototype.commonOptions = function() {
var config = this.config;
var cmd = "geth ";
var cmd = "";
if (config.networkType === 'testnet') {
cmd += "--testnet ";
@ -66,7 +66,11 @@ GethCommands.prototype.listAccountsCommand = function() {
cmd += "--password " + config.account.password + " ";
}
return cmd + "account list ";
return cmd;
};
GethCommands.prototype.listAccountsCommand = function() {
return "geth " + this.commonOptions() + "account list ";
};
GethCommands.prototype.mainCommand = function(address) {
@ -74,21 +78,7 @@ GethCommands.prototype.mainCommand = function(address) {
var cmd = "geth ";
var rpc_api = ['eth', 'web3'];
if (config.datadir) {
cmd += "--datadir=\"" + config.datadir + "\" ";
}
if (config.networkType === 'testnet') {
cmd += "--testnet ";
} else if (config.networkType === 'olympic') {
cmd += "--olympic ";
} else if (config.networkType === 'custom') {
cmd += "--networkid " + config.networkId + " ";
}
if (config.account && config.account.password) {
cmd += "--password " + config.account.password + " ";
}
cmd += this.commonOptions();
cmd += "--port " + "30303" + " ";
cmd += "--rpc ";