diff --git a/package.json b/package.json index 4f5bc19f5e..1079f38c18 100644 --- a/package.json +++ b/package.json @@ -83,21 +83,23 @@ "lodash.get": "^4.4.0", "lodash.set": "^4.3.0", "mafmt": "^2.1.1", - "multihashes": "^0.2.2", "multiaddr": "^2.0.2", + "multihashes": "^0.2.2", "path-exists": "^3.0.0", "peer-book": "^0.3.0", "peer-id": "^0.7.0", "peer-info": "^0.7.0", "promisify-es6": "^1.0.1", + "read-pkg-up": "^1.0.1", "readable-stream": "1.1.13", - "ronin": "^0.3.11", "run-parallel": "^1.1.6", "run-parallel-limit": "^1.0.3", "run-series": "^1.1.4", "run-waterfall": "^1.1.3", "temp": "^0.8.3", - "through2": "^2.0.1" + "through2": "^2.0.1", + "update-notifier": "^1.0.2", + "yargs": "^4.8.1" }, "contributors": [ "Andrew de Andrade ", diff --git a/src/cli/bin.js b/src/cli/bin.js index 4e78c38bb9..f22530c10e 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -2,12 +2,20 @@ 'use strict' -const ronin = require('ronin') +const yargs = require('yargs') +const updateNotifier = require('update-notifier') +const readPkgUp = require('read-pkg-up') -const cli = ronin(__dirname) +const pkg = readPkgUp.sync().pkg +updateNotifier({ + pkg, + updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week +}).notify() -cli.run() - -// cli.autoupdate(function () { -// cli.run() -// }) +yargs + .commandDir('commands') + .demand(1) + .help() + .strict() + .completion() + .argv diff --git a/src/cli/commands/bitswap.js b/src/cli/commands/bitswap.js new file mode 100644 index 0000000000..05284b9763 --- /dev/null +++ b/src/cli/commands/bitswap.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'bitswap', + + description: 'A set of commands to manipulate the bitswap agent.', + + builder (yargs) { + return yargs + .commandDir('bitswap') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/bitswap/stat.js b/src/cli/commands/bitswap/stat.js index e3643ad218..14668e0768 100644 --- a/src/cli/commands/bitswap/stat.js +++ b/src/cli/commands/bitswap/stat.js @@ -1,15 +1,15 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Show some diagnostic information on the bitswap agent.', +module.exports = { + command: 'stat', - options: { - }, + describe: 'Show some diagnostic information on the bitswap agent.', - run: () => { + builder: {}, + + handler () { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -35,4 +35,4 @@ bitswap status }) }) } -}) +} diff --git a/src/cli/commands/bitswap/unwant.js b/src/cli/commands/bitswap/unwant.js index e09ea250cc..7a0feb533d 100644 --- a/src/cli/commands/bitswap/unwant.js +++ b/src/cli/commands/bitswap/unwant.js @@ -1,18 +1,13 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Remove a given block from your wantlist.', +module.exports = { + command: 'unwant ', - options: { - key: { - required: true - } - }, + describe: 'Remove a given block from your wantlist.', - run: (key) => { + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -21,4 +16,4 @@ module.exports = Command.extend({ throw new Error('Not implemented yet') }) } -}) +} diff --git a/src/cli/commands/bitswap/wantlist.js b/src/cli/commands/bitswap/wantlist.js index bd258ff545..eca9424539 100644 --- a/src/cli/commands/bitswap/wantlist.js +++ b/src/cli/commands/bitswap/wantlist.js @@ -1,15 +1,22 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Print out all blocks currently on the bitswap wantlist for the local peer.', +module.exports = { + command: 'wantlist', - options: { + describe: 'Print out all blocks currently on the bitswap wantlist for the local peer.', + + builder: { + peer: { + alias: 'p', + describe: 'Specify which peer to show wantlist for.', + type: 'string' + } }, - run: () => { + handler (argv) { + // TODO: handle argv.peer utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -23,4 +30,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/block.js b/src/cli/commands/block.js new file mode 100644 index 0000000000..599e202b7a --- /dev/null +++ b/src/cli/commands/block.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'block', + + description: 'Manipulate raw IPFS blocks.', + + builder (yargs) { + return yargs + .commandDir('block') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/block/get.js b/src/cli/commands/block/get.js index 7ca1f84432..4af4acfa4c 100644 --- a/src/cli/commands/block/get.js +++ b/src/cli/commands/block/get.js @@ -1,30 +1,27 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const bs58 = require('bs58') const debug = require('debug') const log = debug('cli:block') log.error = debug('cli:block:error') -module.exports = Command.extend({ - desc: 'Get a raw IPFS block', +module.exports = { + command: 'get ', - options: {}, + describe: 'Get a raw IPFS block', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } const mh = utils.isDaemonOn() - ? key - : new Buffer(bs58.decode(key)) + ? argv.key + : new Buffer(bs58.decode(argv.key)) ipfs.block.get(mh, (err, block) => { if (err) { @@ -40,4 +37,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/block/put.js b/src/cli/commands/block/put.js index 619e925669..3c006fd3bb 100644 --- a/src/cli/commands/block/put.js +++ b/src/cli/commands/block/put.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const bs58 = require('bs58') const bl = require('bl') @@ -38,14 +37,16 @@ function addBlock (buf) { }) } -module.exports = Command.extend({ - desc: 'Stores input as an IPFS block', +module.exports = { + command: 'put [data]', - options: {}, + describe: 'Stores input as an IPFS block', - run: (filePath) => { - if (filePath) { - return addBlock(fs.readFileSync(filePath)) + builder: {}, + + handler (argv) { + if (argv.data) { + return addBlock(fs.readFileSync(argv.data)) } process.stdin.pipe(bl((err, input) => { @@ -56,4 +57,4 @@ module.exports = Command.extend({ addBlock(input) })) } -}) +} diff --git a/src/cli/commands/block/rm.js b/src/cli/commands/block/rm.js index 9fea64c4dc..5e2e8783b7 100644 --- a/src/cli/commands/block/rm.js +++ b/src/cli/commands/block/rm.js @@ -1,22 +1,19 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const bs58 = require('bs58') const debug = require('debug') const log = debug('cli:block') log.error = debug('cli:block:error') -module.exports = Command.extend({ - desc: 'Remove a raw IPFS block', +module.exports = { + command: 'rm ', - options: {}, + describe: 'Remove a raw IPFS block', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -27,15 +24,15 @@ module.exports = Command.extend({ throw new Error('rm block with daemon running is not yet implemented') } - const mh = new Buffer(bs58.decode(key)) + const mh = new Buffer(bs58.decode(argv.key)) ipfs.block.del(mh, (err) => { if (err) { throw err } - console.log('removed', key) + console.log('removed', argv.key) }) }) } -}) +} diff --git a/src/cli/commands/block/stat.js b/src/cli/commands/block/stat.js index a7ad13657a..c1107f77df 100644 --- a/src/cli/commands/block/stat.js +++ b/src/cli/commands/block/stat.js @@ -1,30 +1,27 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const bs58 = require('bs58') const debug = require('debug') const log = debug('cli:block') log.error = debug('cli:block:error') -module.exports = Command.extend({ - desc: 'Print information of a raw IPFS block', +module.exports = { + command: 'stat ', - options: {}, + describe: 'Print information of a raw IPFS block', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } const mh = utils.isDaemonOn() - ? key - : new Buffer(bs58.decode(key)) + ? argv.key + : new Buffer(bs58.decode(argv.key)) ipfs.block.stat(mh, (err, block) => { if (err) { @@ -41,4 +38,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/bootstrap.js b/src/cli/commands/bootstrap.js new file mode 100644 index 0000000000..0e2ad80d85 --- /dev/null +++ b/src/cli/commands/bootstrap.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'bootstrap', + + description: 'Show or edit the list of bootstrap peers.', + + builder (yargs) { + return yargs + .commandDir('bootstrap') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/bootstrap/add.js b/src/cli/commands/bootstrap/add.js index 820a78ced0..0122e53fee 100644 --- a/src/cli/commands/bootstrap/add.js +++ b/src/cli/commands/bootstrap/add.js @@ -1,26 +1,27 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const log = debug('cli:bootstrap') const utils = require('../../utils') log.error = debug('cli:bootstrap:error') -module.exports = Command.extend({ - desc: 'Add peers to the bootstrap list', +module.exports = { + command: 'add ', - options: {}, + describe: 'Add peers to the bootstrap list', - run: (multiaddr) => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.bootstrap.add(multiaddr, (err, list) => { + ipfs.bootstrap.add(argv.peer, (err, list) => { if (err) { throw err } }) }) } -}) +} diff --git a/src/cli/commands/bootstrap/list.js b/src/cli/commands/bootstrap/list.js index a6b1478b49..e060ec4461 100644 --- a/src/cli/commands/bootstrap/list.js +++ b/src/cli/commands/bootstrap/list.js @@ -1,17 +1,18 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:bootstrap') log.error = debug('cli:bootstrap:error') -module.exports = Command.extend({ - desc: 'Show peers in the bootstrap list', +module.exports = { + command: 'list', - options: {}, + describe: 'Show peers in the bootstrap list', - run: () => { + builder: {}, + + handler () { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -26,4 +27,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/bootstrap/rm.js b/src/cli/commands/bootstrap/rm.js index 0cf1a93560..03216b6baa 100644 --- a/src/cli/commands/bootstrap/rm.js +++ b/src/cli/commands/bootstrap/rm.js @@ -1,26 +1,27 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const log = debug('cli:bootstrap') log.error = debug('cli:bootstrap:error') const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Removes peers from the bootstrap list', +module.exports = { + command: 'rm ', - options: {}, + describe: 'Removes peers from the bootstrap list', - run: (multiaddr) => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.bootstrap.rm(multiaddr, (err, list) => { + ipfs.bootstrap.rm(argv.peer, (err, list) => { if (err) { throw err } }) }) } -}) +} diff --git a/src/cli/commands/commands.js b/src/cli/commands/commands.js index 91294b1414..ea60b587df 100644 --- a/src/cli/commands/commands.js +++ b/src/cli/commands/commands.js @@ -1,13 +1,14 @@ 'use strict' -const Command = require('ronin').Command const path = require('path') const glob = require('glob').sync -module.exports = Command.extend({ - desc: 'List all available commands', +module.exports = { + command: 'commands', - run (name) { + describe: 'List all available commands', + + handler () { const basePath = path.resolve(__dirname, '..') // modeled after https://github.com/vdemedes/ronin/blob/master/lib/program.js#L78 @@ -24,4 +25,4 @@ module.exports = Command.extend({ console.log(['ipfs'].concat(cmds).join('\n')) } -}) +} diff --git a/src/cli/commands/config.js b/src/cli/commands/config.js index 68d095f47b..ee0e7d377b 100644 --- a/src/cli/commands/config.js +++ b/src/cli/commands/config.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const get = require('lodash.get') const set = require('lodash.set') @@ -8,24 +7,34 @@ const log = debug('cli:config') log.error = debug('cli:config:error') const utils = require('../utils') -module.exports = Command.extend({ - desc: 'Get and set IPFS config values', - - options: { - bool: { - type: 'boolean', - default: false - }, - json: { - type: 'boolean', - default: false - } +module.exports = { + command: 'config [value]', + + description: 'Get and set IPFS config values', + + builder (yargs) { + return yargs + .commandDir('config') + .options({ + bool: { + type: 'boolean', + default: false + }, + json: { + type: 'boolean', + default: false + } + }) }, - run: (bool, json, key, value) => { - if (!key) { - throw new Error("argument 'key' is required") - } + handler (argv) { + if (argv._handled) return + argv._handled = true + + const bool = argv.bool + const json = argv.json + const key = argv.key + let value = argv.value utils.getIPFS((err, ipfs) => { if (err) { @@ -42,7 +51,7 @@ module.exports = Command.extend({ throw new Error('failed to read the config') } - console.log(config.Value) + console.log(config) }) } @@ -95,4 +104,4 @@ module.exports = Command.extend({ } }) } -}) +} diff --git a/src/cli/commands/config/edit.js b/src/cli/commands/config/edit.js index dfe9061199..90502dc059 100644 --- a/src/cli/commands/config/edit.js +++ b/src/cli/commands/config/edit.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const spawn = require('child_process').spawn const fs = require('fs') const temp = require('temp') @@ -10,10 +9,17 @@ const log = debug('cli:config') log.error = debug('cli:config:error') const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Opens the config file for editing in $EDITOR', +module.exports = { + command: 'edit', + + describe: 'Opens the config file for editing in $EDITOR', + + builder: {}, + + handler (argv) { + if (argv._handled) return + argv._handled = true - run: (name) => { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -111,4 +117,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/config/replace.js b/src/cli/commands/config/replace.js index 4b156568bb..fd1a075c97 100644 --- a/src/cli/commands/config/replace.js +++ b/src/cli/commands/config/replace.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const path = require('path') const log = debug('cli:config') @@ -8,18 +7,23 @@ log.error = debug('cli:config:error') const utils = require('../../utils') const fs = require('fs') -module.exports = Command.extend({ - desc: 'Replaces the config with ', +module.exports = { + command: 'replace ', - options: {}, + describe: 'Replaces the config with ', + + builder: {}, + + handler (argv) { + if (argv._handled) return + argv._handled = true - run: (configPath) => { utils.getIPFS((err, ipfs) => { if (err) { throw err } - const filePath = path.resolve(process.cwd(), configPath) + const filePath = path.resolve(process.cwd(), argv.file) const config = utils.isDaemonOn() ? filePath : JSON.parse(fs.readFileSync(filePath, 'utf8')) @@ -31,4 +35,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/config/show.js b/src/cli/commands/config/show.js index 5a837bee6f..225a06b34e 100644 --- a/src/cli/commands/config/show.js +++ b/src/cli/commands/config/show.js @@ -1,17 +1,21 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const log = debug('cli:config') log.error = debug('cli:config:error') const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Outputs the content of the config file', +module.exports = { + command: 'show', - options: {}, + describe: 'Outputs the content of the config file', + + builder: {}, + + handler (argv) { + if (argv._handled) return + argv._handled = true - run: () => { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -25,4 +29,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index 6beddb19b2..acbbc5dc00 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const HttpAPI = require('../../http-api') const debug = require('debug') const log = debug('cli:daemon') @@ -8,10 +7,12 @@ log.error = debug('cli:daemon:error') let httpAPI -module.exports = Command.extend({ - desc: 'Start a long-running daemon process', +module.exports = { + command: 'daemon', - run: (name) => { + describe: 'Start a long-running daemon process', + + handler () { console.log('Initializing daemon...') httpAPI = new HttpAPI(process.env.IPFS_PATH) httpAPI.start((err) => { @@ -31,4 +32,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/dns.js b/src/cli/commands/dns.js index eaa6654b45..fde8059af3 100644 --- a/src/cli/commands/dns.js +++ b/src/cli/commands/dns.js @@ -1,10 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'dns', -module.exports = Command.extend({ - desc: '', + describe: '', - run: () => { + handler (argv) { } -}) +} diff --git a/src/cli/commands/files.js b/src/cli/commands/files.js new file mode 100644 index 0000000000..0b63bdefb6 --- /dev/null +++ b/src/cli/commands/files.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'files', + + description: '', + + builder (yargs) { + return yargs + .commandDir('files') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/files/add.js b/src/cli/commands/files/add.js index 5cae372ccd..5caa5d85a4 100644 --- a/src/cli/commands/files/add.js +++ b/src/cli/commands/files/add.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:version') @@ -35,10 +34,12 @@ function checkPath (inPath, recursive) { return inPath } -module.exports = Command.extend({ - desc: 'Add a file to IPFS using the UnixFS data format', +module.exports = { + command: 'add ', - options: { + describe: 'Add a file to IPFS using the UnixFS data format', + + builder: { recursive: { alias: 'r', type: 'boolean', @@ -46,10 +47,10 @@ module.exports = Command.extend({ } }, - run: (recursive, inPath) => { + handler (argv) { let rs - inPath = checkPath(inPath, recursive) + let inPath = checkPath(argv.file, argv.recursive) glob(path.join(inPath, '/**/*'), (err, res) => { if (err) { @@ -95,4 +96,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/files/cat.js b/src/cli/commands/files/cat.js index ff87a82a69..7129aeed66 100644 --- a/src/cli/commands/files/cat.js +++ b/src/cli/commands/files/cat.js @@ -1,23 +1,19 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const utils = require('../../utils') const log = debug('cli:files') log.error = debug('cli:files:error') -module.exports = Command.extend({ - desc: 'Download IPFS objects', +module.exports = { + command: 'cat ', - options: {}, + describe: 'Download IPFS objects', - run: (path, options) => { - if (!path) { - throw new Error("Argument 'path' is required") - } - if (!options) { - options = {} - } + builder: {}, + + handler (argv) { + const path = argv.ipfsPath utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -39,4 +35,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/files/get.js b/src/cli/commands/files/get.js index e85542dbe2..b8d746c03f 100644 --- a/src/cli/commands/files/get.js +++ b/src/cli/commands/files/get.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const utils = require('../../utils') const log = debug('cli:files') @@ -10,14 +9,7 @@ const path = require('path') const pathExists = require('path-exists') function checkArgs (hash, outPath) { - if (!hash) { - throw new Error("Argument 'path' is required") - } // format the output directory - if (!outPath) { - return process.cwd() - } - if (!outPath.endsWith('/')) { outPath += '/' } @@ -70,17 +62,27 @@ function fileHandler (result, dir) { } } -module.exports = Command.extend({ - desc: 'Download IPFS objects', +module.exports = { + command: 'get ', - run: (hash, outPath) => { - const dir = checkArgs(hash, outPath) + describe: 'Download IPFS objects', + + builder: { + output: { + alias: 'o', + type: 'string', + default: process.cwd() + } + }, + + handler (argv) { + const dir = checkArgs(argv.ipfsPath, argv.output) utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.files.get(hash, (err, result) => { + ipfs.files.get(argv.ipfsPath, (err, result) => { if (err) { throw err } @@ -88,4 +90,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/id.js b/src/cli/commands/id.js index 775b4673f4..0ccd56af00 100644 --- a/src/cli/commands/id.js +++ b/src/cli/commands/id.js @@ -1,33 +1,35 @@ 'use strict' -const Command = require('ronin').Command const debug = require('debug') const utils = require('../utils') const log = debug('cli') log.error = debug('cli:error') -module.exports = Command.extend({ - desc: 'Shows IPFS Node ID info', +module.exports = { + command: 'id', - options: { + describe: 'Shows IPFS Node ID info', + + builder: { format: { alias: 'f', type: 'string' } }, - run: (name) => { + handler (argv) { + // TODO: handle argv.format utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.id((err, id) => { if (err) { throw err } + console.log(JSON.stringify(id, '', 2)) }) }) } -}) +} diff --git a/src/cli/commands/init.js b/src/cli/commands/init.js index 5572bfb623..24313cc217 100644 --- a/src/cli/commands/init.js +++ b/src/cli/commands/init.js @@ -1,50 +1,52 @@ 'use strict' -const Command = require('ronin').Command const IpfsRepo = require('ipfs-repo') const Ipfs = require('../../core') const fsBlobStore = require('fs-blob-store') const utils = require('../utils') -module.exports = Command.extend({ - desc: 'Initialize a local IPFS node', +module.exports = { + command: 'init', - options: { + describe: 'Initialize a local IPFS node', + + builder: { bits: { type: 'number', alias: 'b', default: '2048', - desc: 'Number of bits to use in the generated RSA private key (defaults to 2048)' + describe: 'Number of bits to use in the generated RSA private key (defaults to 2048)' }, force: { alias: 'f', type: 'boolean', - desc: 'Overwrite existing config (if it exists)' + describe: 'Overwrite existing config (if it exists)' }, - 'empty-repo': { + emptyRepo: { alias: 'e', type: 'boolean', - desc: "Don't add and pin help files to the local storage" + describe: "Don't add and pin help files to the local storage" } }, - run: (bits, force, empty) => { + handler (argv) { const path = utils.getRepoPath() const repo = new IpfsRepo(path, { stores: fsBlobStore }) - var ipfs = new Ipfs(repo) + const ipfs = new Ipfs(repo) + ipfs.init({ - bits: bits, - force: force, - emptyRepo: empty - }, function (err, res) { + bits: argv.bits, + force: argv.force, + emptyRepo: argv.emptyRepo + }, function (err) { if (err) { console.error(err.toString()) process.exit(1) } }) } -}) +} diff --git a/src/cli/commands/ls.js b/src/cli/commands/ls.js index a46afd1faa..d1210bdd28 100644 --- a/src/cli/commands/ls.js +++ b/src/cli/commands/ls.js @@ -1,9 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'ls', -module.exports = Command.extend({ - desc: '', + describe: '', - run: () => {} -}) + handler (argv) { + } +} diff --git a/src/cli/commands/mount.js b/src/cli/commands/mount.js index af4020b384..7825753efb 100644 --- a/src/cli/commands/mount.js +++ b/src/cli/commands/mount.js @@ -1,10 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'mount', -module.exports = Command.extend({ - desc: '', + describe: '', - run: (name) => { + handler (argv) { } -}) +} diff --git a/src/cli/commands/object.js b/src/cli/commands/object.js new file mode 100644 index 0000000000..9f29944eff --- /dev/null +++ b/src/cli/commands/object.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'object', + + description: 'Interact with ipfs objects.', + + builder (yargs) { + return yargs + .commandDir('object') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/object/data.js b/src/cli/commands/object/data.js index 173608bf05..7dfb371568 100644 --- a/src/cli/commands/object/data.js +++ b/src/cli/commands/object/data.js @@ -1,27 +1,24 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Outputs the raw bytes in an IPFS object', +module.exports = { + command: 'data ', - options: {}, + describe: 'Outputs the raw bytes in an IPFS object', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.object.data(key, {enc: 'base58'}, (err, data) => { + ipfs.object.data(argv.key, {enc: 'base58'}, (err, data) => { if (err) { throw err } @@ -30,4 +27,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/get.js b/src/cli/commands/object/get.js index afd08948b7..59796e9821 100644 --- a/src/cli/commands/object/get.js +++ b/src/cli/commands/object/get.js @@ -1,27 +1,24 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Get and serialize the DAG node named by ', +module.exports = { + command: 'get ', - options: {}, + describe: 'Get and serialize the DAG node named by ', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.object.get(key, {enc: 'base58'}, (err, node) => { + ipfs.object.get(argv.key, {enc: 'base58'}, (err, node) => { if (err) { throw err } @@ -32,4 +29,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/links.js b/src/cli/commands/object/links.js index b2d0959013..707a0cd44d 100644 --- a/src/cli/commands/object/links.js +++ b/src/cli/commands/object/links.js @@ -1,27 +1,24 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Outputs the links pointed to by the specified object', +module.exports = { + command: 'links ', - options: {}, + describe: 'Outputs the links pointed to by the specified object', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.object.links(key, {enc: 'base58'}, (err, links) => { + ipfs.object.links(argv.key, {enc: 'base58'}, (err, links) => { if (err) { throw err } @@ -33,4 +30,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/new.js b/src/cli/commands/object/new.js index e7b0f4b2b2..4cb570497a 100644 --- a/src/cli/commands/object/new.js +++ b/src/cli/commands/object/new.js @@ -1,17 +1,18 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Create new ipfs objects', +module.exports = { + command: 'new', - options: {}, + describe: 'Create new ipfs objects', - run: () => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -26,4 +27,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/patch.js b/src/cli/commands/object/patch.js new file mode 100644 index 0000000000..348947cf48 --- /dev/null +++ b/src/cli/commands/object/patch.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'patch', + + description: 'Create a new merkledag object based on an existing one.', + + builder (yargs) { + return yargs + .commandDir('patch') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/object/patch/add-link.js b/src/cli/commands/object/patch/add-link.js index e5837c615f..8ec24eebb8 100644 --- a/src/cli/commands/object/patch/add-link.js +++ b/src/cli/commands/object/patch/add-link.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../../utils') const debug = require('debug') const log = debug('cli:object') @@ -8,34 +7,26 @@ const mDAG = require('ipfs-merkle-dag') const DAGLink = mDAG.DAGLink log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Add a link to a given object', +module.exports = { + command: 'add-link ', - options: {}, + describe: 'Add a link to a given object', - run: (root, name, ref) => { - if (!root) { - throw new Error("Argument 'root' is required") - } - if (!name) { - throw new Error("Argument 'name' is required") - } - if (!ref) { - throw new Error("Argument 'ref' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.object.get(ref, {enc: 'base58'}).then((linkedObj) => { + ipfs.object.get(argv.ref, {enc: 'base58'}).then((linkedObj) => { const link = new DAGLink( - name, + argv.name, linkedObj.size(), linkedObj.multihash() ) - return ipfs.object.patch.addLink(root, link, {enc: 'base58'}) + return ipfs.object.patch.addLink(argv.root, link, {enc: 'base58'}) }).then((node) => { console.log(node.toJSON().Hash) }).catch((err) => { @@ -43,4 +34,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/patch/append-data.js b/src/cli/commands/object/patch/append-data.js index dd420943b7..4aafbfbb16 100644 --- a/src/cli/commands/object/patch/append-data.js +++ b/src/cli/commands/object/patch/append-data.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../../utils') const bl = require('bl') const fs = require('fs') @@ -24,18 +23,16 @@ function appendData (key, data) { }) } -module.exports = Command.extend({ - desc: 'Append data to the data segment of a dag node', +module.exports = { + command: 'append-data [data]', - options: {}, + describe: 'Append data to the data segment of a dag node', - run: (key, filePath) => { - if (!key) { - throw new Error("Argument 'root' is required") - } + builder: {}, - if (filePath) { - return appendData(key, fs.readFileSync(filePath)) + handler (argv) { + if (argv.data) { + return appendData(argv.root, fs.readFileSync(argv.data)) } process.stdin.pipe(bl((err, input) => { @@ -43,7 +40,7 @@ module.exports = Command.extend({ throw err } - appendData(key, input) + appendData(argv.root, input) })) } -}) +} diff --git a/src/cli/commands/object/patch/rm-link.js b/src/cli/commands/object/patch/rm-link.js index 430ebb3fda..9aa22645cc 100644 --- a/src/cli/commands/object/patch/rm-link.js +++ b/src/cli/commands/object/patch/rm-link.js @@ -1,33 +1,27 @@ 'use strict' -const Command = require('ronin').Command const DAGLink = require('ipfs-merkle-dag').DAGLink const utils = require('../../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Remove a link from an object', +module.exports = { + command: 'rm-link ', - options: {}, + describe: 'Remove a link from an object', - run: (root, link) => { - if (!root) { - throw new Error("Argument 'root' is required") - } - if (!link) { - throw new Error("Argument 'link' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - const dLink = new DAGLink(link) + const dLink = new DAGLink(argv.link) - ipfs.object.patch.rmLink(root, dLink, {enc: 'base58'}, (err, node) => { + ipfs.object.patch.rmLink(argv.root, dLink, {enc: 'base58'}, (err, node) => { if (err) { throw err } @@ -36,4 +30,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/object/patch/set-data.js b/src/cli/commands/object/patch/set-data.js index abbe115cf5..d24791c8eb 100644 --- a/src/cli/commands/object/patch/set-data.js +++ b/src/cli/commands/object/patch/set-data.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../../utils') const bl = require('bl') const fs = require('fs') @@ -24,18 +23,16 @@ function parseAndAddNode (key, data) { }) } -module.exports = Command.extend({ - desc: 'Set data field of an ipfs object', +module.exports = { + command: 'set-data [data]', - options: {}, + describe: 'Set data field of an ipfs object', - run: (key, filePath) => { - if (!key) { - throw new Error("Argument 'root' is required") - } + builder: {}, - if (filePath) { - return parseAndAddNode(key, fs.readFileSync(filePath)) + handler (argv) { + if (argv.data) { + return parseAndAddNode(argv.root, fs.readFileSync(argv.data)) } process.stdin.pipe(bl((err, input) => { @@ -43,7 +40,7 @@ module.exports = Command.extend({ throw err } - parseAndAddNode(key, input) + parseAndAddNode(argv.root, input) })) } -}) +} diff --git a/src/cli/commands/object/put.js b/src/cli/commands/object/put.js index 8b8054a2f5..5ce124f261 100644 --- a/src/cli/commands/object/put.js +++ b/src/cli/commands/object/put.js @@ -1,6 +1,5 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const bl = require('bl') const fs = require('fs') @@ -24,19 +23,21 @@ function putNode (buf, enc) { }) } -module.exports = Command.extend({ - desc: 'Stores input as a DAG object, outputs its key', +module.exports = { + command: 'put [data]', - options: { + describe: 'Stores input as a DAG object, outputs its key', + + builder: { inputenc: { type: 'string', default: 'json' } }, - run: (inputenc, filePath) => { - if (filePath) { - return putNode(fs.readFileSync(filePath), inputenc) + handler (argv) { + if (argv.data) { + return putNode(fs.readFileSync(argv.data), argv.inputenc) } process.stdin.pipe(bl((err, input) => { @@ -44,7 +45,7 @@ module.exports = Command.extend({ throw err } - putNode(input, inputenc) + putNode(input, argv.inputenc) })) } -}) +} diff --git a/src/cli/commands/object/stat.js b/src/cli/commands/object/stat.js index a819ae0e2b..ac1da4382a 100644 --- a/src/cli/commands/object/stat.js +++ b/src/cli/commands/object/stat.js @@ -1,27 +1,24 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'Get stats for the DAG node named by ', +module.exports = { + command: 'stat ', - options: {}, + describe: 'Get stats for the DAG node named by ', - run: (key) => { - if (!key) { - throw new Error("Argument 'key' is required") - } + builder: {}, + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.object.stat(key, {enc: 'base58'}, (err, stats) => { + ipfs.object.stat(argv.key, {enc: 'base58'}, (err, stats) => { if (err) { throw err } @@ -34,4 +31,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/ping.js b/src/cli/commands/ping.js index a46afd1faa..d6a040231c 100644 --- a/src/cli/commands/ping.js +++ b/src/cli/commands/ping.js @@ -1,9 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'ping', -module.exports = Command.extend({ - desc: '', + describe: '', - run: () => {} -}) + handler (argv) { + } +} diff --git a/src/cli/commands/refs.js b/src/cli/commands/refs.js index af4020b384..3d4f4ef4ab 100644 --- a/src/cli/commands/refs.js +++ b/src/cli/commands/refs.js @@ -1,10 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'refs', -module.exports = Command.extend({ - desc: '', + describe: '', - run: (name) => { + handler (argv) { } -}) +} diff --git a/src/cli/commands/repo.js b/src/cli/commands/repo.js new file mode 100644 index 0000000000..e67ebfa3e7 --- /dev/null +++ b/src/cli/commands/repo.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'repo', + + description: 'Manipulate the IPFS repo.', + + builder (yargs) { + return yargs + .commandDir('repo') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/repo/gc.js b/src/cli/commands/repo/gc.js index 1d7948d62d..6b6f705cf4 100644 --- a/src/cli/commands/repo/gc.js +++ b/src/cli/commands/repo/gc.js @@ -1,11 +1,12 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'gc', -module.exports = Command.extend({ - desc: '', + describe: '', - options: {}, + builder: {}, - run: function () {} -}) + handler (argv) { + } +} diff --git a/src/cli/commands/repo/init.js b/src/cli/commands/repo/init.js index 1d7948d62d..a4e7e406da 100644 --- a/src/cli/commands/repo/init.js +++ b/src/cli/commands/repo/init.js @@ -1,11 +1,12 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'init', -module.exports = Command.extend({ - desc: '', + describe: '', - options: {}, + builder: {}, - run: function () {} -}) + handler (argv) { + } +} diff --git a/src/cli/commands/repo/version.js b/src/cli/commands/repo/version.js index 7885b99b40..d1c6a57c96 100644 --- a/src/cli/commands/repo/version.js +++ b/src/cli/commands/repo/version.js @@ -1,14 +1,15 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') -module.exports = Command.extend({ - desc: 'Shows IPFS repo version information', +module.exports = { + command: 'version', - options: {}, + describe: 'Shows IPFS repo version information', - run: function () { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -21,4 +22,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/resolve.js b/src/cli/commands/resolve.js index a46afd1faa..d57a017114 100644 --- a/src/cli/commands/resolve.js +++ b/src/cli/commands/resolve.js @@ -1,9 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'resolve', -module.exports = Command.extend({ - desc: '', + describe: '', - run: () => {} -}) + handler (argv) { + } +} diff --git a/src/cli/commands/swarm.js b/src/cli/commands/swarm.js new file mode 100644 index 0000000000..dc7cd291d1 --- /dev/null +++ b/src/cli/commands/swarm.js @@ -0,0 +1,15 @@ +'use strict' + +module.exports = { + command: 'swarm', + + description: 'Swarm inspection tool.', + + builder (yargs) { + return yargs + .commandDir('swarm') + }, + + handler (argv) { + } +} diff --git a/src/cli/commands/swarm/addrs.js b/src/cli/commands/swarm/addrs.js index aa6802e69f..2a9630c321 100644 --- a/src/cli/commands/swarm/addrs.js +++ b/src/cli/commands/swarm/addrs.js @@ -1,17 +1,21 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: '', +module.exports = { + command: 'addrs', - options: {}, + describe: '', - run: () => { + builder (yargs) { + return yargs + .commandDir('addrs') + }, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -19,4 +23,4 @@ module.exports = Command.extend({ // TODO }) } -}) +} diff --git a/src/cli/commands/swarm/addrs/local.js b/src/cli/commands/swarm/addrs/local.js index 2ba6c510a1..92a35a2524 100644 --- a/src/cli/commands/swarm/addrs/local.js +++ b/src/cli/commands/swarm/addrs/local.js @@ -1,17 +1,18 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'List local addresses', +module.exports = { + command: 'local', - options: {}, + describe: 'List local addresses', - run: () => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -32,4 +33,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/swarm/connect.js b/src/cli/commands/swarm/connect.js index dfa4a0932f..234bb2b69d 100644 --- a/src/cli/commands/swarm/connect.js +++ b/src/cli/commands/swarm/connect.js @@ -1,19 +1,20 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:swarm') log.error = debug('cli:swarm:error') -module.exports = Command.extend({ - desc: 'Open connection to a given address', +module.exports = { + command: 'connect
', - options: {}, + describe: 'Open connection to a given address', - run: (address) => { - if (!address) { - throw new Error("Argument 'address' is required") + builder: {}, + + handler (argv) { + if (!utils.isDaemonOn()) { + throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.') } utils.getIPFS((err, ipfs) => { @@ -21,11 +22,7 @@ module.exports = Command.extend({ throw err } - if (!utils.isDaemonOn()) { - throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.') - } - - ipfs.swarm.connect(address, (err, res) => { + ipfs.swarm.connect(argv.address, (err, res) => { if (err) { throw err } @@ -34,4 +31,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/swarm/disconnect.js b/src/cli/commands/swarm/disconnect.js index 6ce8687868..9cc88e958f 100644 --- a/src/cli/commands/swarm/disconnect.js +++ b/src/cli/commands/swarm/disconnect.js @@ -1,18 +1,19 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') // const bs58 = require('bs58') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: '', +module.exports = { + command: 'disconnect
', - options: {}, + describe: '', - run: () => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -20,4 +21,4 @@ module.exports = Command.extend({ // TODO }) } -}) +} diff --git a/src/cli/commands/swarm/peers.js b/src/cli/commands/swarm/peers.js index 3e4c890ee7..e26db3e106 100644 --- a/src/cli/commands/swarm/peers.js +++ b/src/cli/commands/swarm/peers.js @@ -1,17 +1,18 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../../utils') const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') -module.exports = Command.extend({ - desc: 'List peers with open connections', +module.exports = { + command: 'peers', - options: {}, + describe: 'List peers with open connections', - run: () => { + builder: {}, + + handler (argv) { utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -32,4 +33,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/src/cli/commands/update.js b/src/cli/commands/update.js index af4020b384..56923c5699 100644 --- a/src/cli/commands/update.js +++ b/src/cli/commands/update.js @@ -1,10 +1,10 @@ 'use strict' -const Command = require('ronin').Command +module.exports = { + command: 'update', -module.exports = Command.extend({ - desc: '', + describe: '', - run: (name) => { + handler (argv) { } -}) +} diff --git a/src/cli/commands/version.js b/src/cli/commands/version.js index 1f55de77b2..39ab268348 100644 --- a/src/cli/commands/version.js +++ b/src/cli/commands/version.js @@ -1,15 +1,16 @@ 'use strict' -const Command = require('ronin').Command const utils = require('../utils') const debug = require('debug') const log = debug('cli:version') log.error = debug('cli:version:error') -module.exports = Command.extend({ - desc: 'Shows IPFS version information', +module.exports = { + command: 'version', - options: { + describe: 'Shows IPFS version information', + + builder: { number: { alias: 'n', type: 'boolean', @@ -25,7 +26,8 @@ module.exports = Command.extend({ } }, - run: () => { + handler (argv) { + // TODO: handle argv.{repo|commit|number} utils.getIPFS((err, ipfs) => { if (err) { throw err @@ -44,4 +46,4 @@ module.exports = Command.extend({ }) }) } -}) +} diff --git a/test/cli/test-commands.js b/test/cli/test-commands.js index 7234f283a3..ca3492e00a 100644 --- a/test/cli/test-commands.js +++ b/test/cli/test-commands.js @@ -10,7 +10,7 @@ describe('commands', () => { .run((err, stdout, exitcode) => { expect(err).to.not.exist expect(exitcode).to.equal(0) - expect(stdout.length).to.equal(48) + expect(stdout.length).to.equal(56) done() }) }) diff --git a/test/cli/test-config.js b/test/cli/test-config.js index bad738937b..dbf84abfc6 100644 --- a/test/cli/test-config.js +++ b/test/cli/test-config.js @@ -74,8 +74,6 @@ describe('config', () => { it('set a config key with invalid json', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'config', 'foo', '{"bar: 0}', '--json'], {env}) .run((err, stdout, exitcode) => { - const expected = 'error\tinvalid JSON provided' - expect(stdout[0]).to.equal(expected) expect(err).to.not.exist expect(exitcode).to.equal(1) done() @@ -85,8 +83,6 @@ describe('config', () => { it('call config with no arguments', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'config'], {env}) .run((err, stdout, exitcode) => { - const expected = "error\targument 'key' is required" - expect(stdout[0]).to.equal(expected) expect(err).to.not.exist expect(exitcode).to.equal(1) done() @@ -190,8 +186,6 @@ describe('config', () => { it('set a config key with invalid json', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'config', 'foo', '{"bar: 0}', '--json'], {env}) .run((err, stdout, exitcode) => { - const expected = 'error\tinvalid JSON provided' - expect(stdout[0]).to.equal(expected) expect(err).to.not.exist expect(exitcode).to.equal(1) done() @@ -201,8 +195,6 @@ describe('config', () => { it('call config with no arguments', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'config'], {env}) .run((err, stdout, exitcode) => { - const expected = "error\targument 'key' is required" - expect(stdout[0]).to.equal(expected) expect(err).to.not.exist expect(exitcode).to.equal(1) done() diff --git a/test/cli/test-id.js b/test/cli/test-id.js index 801d69bacd..d41596649b 100644 --- a/test/cli/test-id.js +++ b/test/cli/test-id.js @@ -58,8 +58,6 @@ describe('id', () => { it('get the id', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'], {env}) .run((err, stdout, exitcode) => { - console.log('=> \n', stdout) - expect( stdout ).to.be.eql([