diff --git a/src/cli/bin.js b/src/cli/bin.js index 1d53444ac9..4e666d2a20 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -29,6 +29,7 @@ const cli = yargs default: '' }) .commandDir('commands') + .epilog(utils.ipfsPathHelp) .demandCommand(1) .fail((msg, err, yargs) => { if (err) { diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index ba9ca6ad6a..457dbc4c9d 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -11,15 +11,17 @@ module.exports = { describe: 'Start a long-running daemon process', - builder: { - 'enable-sharding-experiment': { - type: 'boolean', - default: false - }, - 'enable-pubsub-experiment': { - type: 'boolean', - default: false - } + builder (yargs) { + return yargs + .epilog(utils.ipfsPathHelp) + .option('enable-sharding-experiment', { + type: 'boolean', + default: false + }) + .option('enable-pubsub-experiment', { + type: 'boolean', + default: false + }) }, handler (argv) { diff --git a/src/cli/commands/init.js b/src/cli/commands/init.js index 920519f90c..36525419b4 100644 --- a/src/cli/commands/init.js +++ b/src/cli/commands/init.js @@ -5,19 +5,14 @@ const IPFS = require('../../core') const utils = require('../utils') const print = utils.print -const ipfsPathHelp = 'ipfs uses a repository in the local file system. By default, the repo is ' + - 'located at ~/.ipfs.\nTo change the repo location, set the $IPFS_PATH environment variable:\n\n' + - '\texport IPFS_PATH=/path/to/ipfsrepo\n' - module.exports = { command: 'init', describe: 'Initialize a local IPFS node', builder (yargs) { - print(ipfsPathHelp) - return yargs + .epilog(utils.ipfsPathHelp) .option('bits', { type: 'number', alias: 'b', diff --git a/src/cli/utils.js b/src/cli/utils.js index 37cd49010f..b0fd5ff742 100644 --- a/src/cli/utils.js +++ b/src/cli/utils.js @@ -111,3 +111,7 @@ exports.rightpad = (val, n) => { } return result } + +exports.ipfsPathHelp = 'ipfs uses a repository in the local file system. By default, the repo is ' + + 'located at ~/.jsipfs. To change the repo location, set the $IPFS_PATH environment variable:\n\n' + + 'export IPFS_PATH=/path/to/ipfsrepo\n' diff --git a/test/cli/daemon.js b/test/cli/daemon.js index 3245400320..4d5716df41 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -120,4 +120,13 @@ describe('daemon', () => { done() }) }) + + it('should present ipfs path help when option help is received', function (done) { + this.timeout(100 * 1000) + + ipfs('daemon --help').then((res) => { + expect(res).to.have.string('export IPFS_PATH=/path/to/ipfsrepo') + done() + }) + }) }) diff --git a/test/cli/init.js b/test/cli/init.js index 1c5fcf1a1d..86e0dbacda 100644 --- a/test/cli/init.js +++ b/test/cli/init.js @@ -66,4 +66,13 @@ describe('init', function () { expect(repoExistsSync('version')).to.equal(true) }) }) + + it('should present ipfs path help when option help is received', function (done) { + this.timeout(100 * 1000) + + ipfs('init --help').then((res) => { + expect(res).to.have.string('export IPFS_PATH=/path/to/ipfsrepo') + done() + }) + }) })