diff --git a/src/cli/bin.js b/src/cli/bin.js index 67e60f8362..1d53444ac9 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -14,6 +14,8 @@ updateNotifier({ updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week }).notify() +const args = process.argv.slice(2) + const cli = yargs .option('silent', { desc: 'Write no output', @@ -32,6 +34,11 @@ const cli = yargs if (err) { throw err // preserve stack } + + if (args.length > 0) { + print(msg) + } + yargs.showHelp() }) @@ -46,14 +53,12 @@ aliases.forEach((alias) => { cli.command(alias.command, alias.describe, alias.builder, alias.handler) }) -const args = process.argv.slice(2) - // Need to skip to avoid locking as these commands // don't require a daemon if (args[0] === 'daemon' || args[0] === 'init') { cli .help() - .strict(false) + .strict() .completion() .parse(args) } else { @@ -69,7 +74,7 @@ if (args[0] === 'daemon' || args[0] === 'init') { cli .help() - .strict(false) + .strict() .completion() .parse(args, { ipfs: ipfs }, (err, argv, output) => { if (output) { print(output) } diff --git a/src/cli/commands/files/cat.js b/src/cli/commands/files/cat.js index c9cc3037d6..43c22ceb21 100644 --- a/src/cli/commands/files/cat.js +++ b/src/cli/commands/files/cat.js @@ -1,14 +1,14 @@ 'use strict' module.exports = { - command: 'cat ', + command: 'cat ', describe: 'Fetch and cat an IPFS path referencing a file', builder: {}, handler (argv) { - let path = argv['ipfs-path'] + let path = argv['ipfsPath'] if (path.indexOf('/ipfs/') !== 1) { path = path.replace('/ipfs/', '') } diff --git a/src/cli/commands/files/get.js b/src/cli/commands/files/get.js index 85ee810671..c177fb8719 100644 --- a/src/cli/commands/files/get.js +++ b/src/cli/commands/files/get.js @@ -45,7 +45,7 @@ function fileHandler (dir) { } module.exports = { - command: 'get ', + command: 'get ', describe: 'Fetch a file or directory with files references from an IPFS Path', @@ -58,7 +58,8 @@ module.exports = { }, handler (argv) { - const ipfsPath = argv['ipfs-path'] + const ipfsPath = argv['ipfsPath'] + const dir = checkArgs(ipfsPath, argv.output) const stream = argv.ipfs.files.getReadableStream(ipfsPath) diff --git a/test/cli/general.js b/test/cli/general.js index 5a36e1529b..0f20466fcd 100644 --- a/test/cli/general.js +++ b/test/cli/general.js @@ -10,4 +10,12 @@ describe('general cli options', () => runOnAndOff.off((thing) => { expect(out).to.be.empty() }) }) + + it('should handle unknown arguments correctly', () => { + return thing.ipfs('random --again').then((out) => { + expect(out).to.include('Unknown arguments: again, random') + expect(out).to.include('random') + expect(out).to.include('again') + }) + }) }))