From db523472c1a6bb764ebdb84401a3c63fc2ad73b3 Mon Sep 17 00:00:00 2001 From: Francisco Baio Dias Date: Fri, 4 Mar 2016 17:45:58 +0000 Subject: [PATCH] Add ipfs commands to cli --- src/cli/commands/commands.js | 12 ++++++++++++ tests/test-cli/test-commands.js | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/test-cli/test-commands.js diff --git a/src/cli/commands/commands.js b/src/cli/commands/commands.js index b86b5708e4..27115faa3c 100644 --- a/src/cli/commands/commands.js +++ b/src/cli/commands/commands.js @@ -1,10 +1,22 @@ 'use strict' const Command = require('ronin').Command +const path = require('path') +const ronin = require('ronin') module.exports = Command.extend({ desc: '', run: name => { + const cli = ronin(path.resolve(__dirname, '..')) + + cli.setupCommands() + + const commands = [''] + .concat(Object.keys(cli.commands)) + .map((command) => 'ipfs ' + command) + .join('\n') + + console.log(commands) } }) diff --git a/tests/test-cli/test-commands.js b/tests/test-cli/test-commands.js new file mode 100644 index 0000000000..b6ab3bee22 --- /dev/null +++ b/tests/test-cli/test-commands.js @@ -0,0 +1,16 @@ +/* eslint-env mocha */ + +const expect = require('chai').expect +const nexpect = require('nexpect') + +describe('commands', () => { + it('list the commands', (done) => { + nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'commands']) + .run((err, stdout, exitcode) => { + expect(err).to.not.exist + expect(exitcode).to.equal(0) + expect(stdout.length).to.equal(26) + done() + }) + }) +})