diff --git a/bin/cmd.js b/bin/cmd.js index 8a8f573..9fd2ca9 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -9,6 +9,13 @@ var argv = minimist(process.argv.slice(2)) var command = argv._[0] +if (argv['file']) +{ + var file = argv['file'] + console.log(chalk.yellow('Opening file: ' + file)) + hostile.setFile(file); +} + if (command === 'list' || command === 'ls') list() if (command === 'set') set(argv._[1], argv._[2]) if (command === 'remove') remove(argv._[1]) @@ -30,6 +37,8 @@ function help () { remove [domain] Remove a domain from the hosts file load [file] Load a set of host entries from a file unload [file] Remove a set of host entries from a file + + optional --file parameter to all commands to allow for manipulating other hosts files in non standard locations */ }.toString().split(/\n/).slice(1, -1).join('\n')) } diff --git a/index.js b/index.js index d1e7bcf..f369283 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,11 @@ exports.HOSTS = WINDOWS * @param {function(err, lines)=} cb */ +exports.setFile = function(filePath) +{ + exports.HOSTS = filePath +} + exports.getFile = function (filePath, preserveFormatting, cb) { var lines = [] if (typeof cb !== 'function') {