From bbe561b7b1bf068eb703082c30cefa0f3e659d4d Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 30 Jan 2019 10:26:03 +0000 Subject: [PATCH] chore: rename local option to offline (#1850) BREAKING CHANGE: `--local` option has been renamed to `--offline` --- src/cli/commands/daemon.js | 4 ++-- src/core/components/name.js | 10 +++++----- src/core/components/start.js | 4 ++-- src/core/config.js | 2 +- src/http/index.js | 2 +- test/cli/name.js | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index 6f0a3fb406..71024150de 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -26,8 +26,8 @@ module.exports = { type: 'boolean', default: false }) - .option('local', { - desc: 'Run commands locally to the daemon', + .option('offline', { + desc: 'Run offline. Do not connect to the rest of the network but provide local API.', default: false }) .option('enable-namesys-pubsub', { diff --git a/src/core/components/name.js b/src/core/components/name.js index 6c734a35b2..d14241976a 100644 --- a/src/core/components/name.js +++ b/src/core/components/name.js @@ -129,9 +129,9 @@ module.exports = function name (self) { const nocache = options.nocache && options.nocache.toString() === 'true' const recursive = options.recursive && options.recursive.toString() === 'true' - const local = self._options.local + const offline = self._options.offline - if (!self.isOnline() && !local) { + if (!self.isOnline() && !offline) { const errMsg = utils.OFFLINE_ERROR log.error(errMsg) @@ -140,11 +140,11 @@ module.exports = function name (self) { // TODO: params related logic should be in the core implementation - if (local && nocache) { - const error = 'cannot specify both local and nocache' + if (offline && nocache) { + const error = 'cannot specify both offline and nocache' log.error(error) - return callback(errcode(new Error(error), 'ERR_NOCACHE_AND_LOCAL')) + return callback(errcode(new Error(error), 'ERR_NOCACHE_AND_OFFLINE')) } // Set node id as name for being resolved, if it is not received diff --git a/src/core/components/start.js b/src/core/components/start.js index 98f5e52650..e306bf10e2 100644 --- a/src/core/components/start.js +++ b/src/core/components/start.js @@ -67,9 +67,9 @@ module.exports = (self) => { ipnsStores.push(pubsubDs) } - // DHT should be added as routing if we are not running with local flag + // DHT should be added as routing if we are not running with offline flag // TODO: Need to change this logic once DHT is enabled by default, for now fallback to Offline datastore - if (get(self._options, 'EXPERIMENTAL.dht', false) && !self._options.local) { + if (get(self._options, 'EXPERIMENTAL.dht', false) && !self._options.offline) { ipnsStores.push(self.libp2p.dht) } else { const offlineDatastore = new OfflineDatastore(self._repo) diff --git a/src/core/config.js b/src/core/config.js index acad9d877f..c3b9e892a4 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -18,7 +18,7 @@ const schema = Joi.object().keys({ Joi.object().keys({ bits: Joi.number().integer() }) ).allow(null), start: Joi.boolean(), - local: Joi.boolean(), + offline: Joi.boolean(), pass: Joi.string().allow(''), relay: Joi.object().keys({ enabled: Joi.boolean(), diff --git a/src/http/index.js b/src/http/index.js index e80c6b609f..f35b05d075 100644 --- a/src/http/index.js +++ b/src/http/index.js @@ -81,7 +81,7 @@ function HttpApi (repo, config, cliArgs) { init: init, start: true, config: config, - local: cliArgs.local, + offline: cliArgs.offline, pass: cliArgs.pass, EXPERIMENTAL: { pubsub: cliArgs.enablePubsubExperiment, diff --git a/test/cli/name.js b/test/cli/name.js index dbdaff9407..c69b9e2918 100644 --- a/test/cli/name.js +++ b/test/cli/name.js @@ -36,7 +36,7 @@ describe('name', () => { config: { Bootstrap: [] }, - args: ['--pass', passPhrase, '--local'], + args: ['--pass', passPhrase, '--offline'], initOptions: { bits: 512 } }, (err, _ipfsd) => { expect(err).to.not.exist()