Skip to content

Commit

Permalink
tom: add support for ip/port
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Howe committed Sep 8, 2014
1 parent e8369af commit cc2d636
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions bin/etcd-dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ var prog = require('commander');
// etcd-dump's package.json file
var pkg = require('../package.json');

// Dumper class
var dumper = require('../')();

// General options
prog
.version(pkg.version)
.option('-f, --file [json_file]', 'Path to JSON dump file for dumping/storing', './etcd_dump.json');
.option('-f, --file [json_file]', 'Path to JSON dump file for dumping/storing', './etcd_dump.json')
.option('-h, --host [host]', 'Hostname to connect to', 'localhost')
.option('-p, --port [port]', 'Port to connect to', '4001')
;

// Dump command
prog
.command('dump')
.action(function() {
var dumper = require('../')(prog.host, prog.port);

return dumper.dump()
.then(function(data) {
// Write file to disk
Expand All @@ -34,6 +37,7 @@ prog
prog
.command('restore')
.action(function() {
var dumper = require('../')(prog.host, prog.port);
var entries = JSON.parse(fs.readFileSync(prog.file));

return dumper.restore(entries)
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function normalize(obj) {
}


function Dumper(etcd) {
function Dumper(host,port) {
// ETCD client
this.store = new Etcd();
this.store = new Etcd(host, port);

_.bindAll(this);
}
Expand All @@ -47,8 +47,8 @@ Dumper.prototype.restore = function(entries) {
};

// Restore the database from input data
function createDumper() {
return new Dumper();
function createDumper(host,port) {
return new Dumper(host,port);
}

// Exports
Expand Down

0 comments on commit cc2d636

Please sign in to comment.