Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Add ipfs commands to cli #78

Merged
merged 1 commit into from
Mar 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cli/commands/commands.js
Original file line number Diff line number Diff line change
@@ -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, '..'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a ronin inside a ronin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but couldn't find out any other way of doing it 😟
Requiring src/cli/index didn't work as it only got the commands afterwards.

However this is not a full ronin as .run() isn't called :)


cli.setupCommands()

const commands = ['']
.concat(Object.keys(cli.commands))
.map((command) => 'ipfs ' + command)
.join('\n')

console.log(commands)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be sweet if arrays had by default a streams interface :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at http://highlandjs.org/ :)

}
})
16 changes: 16 additions & 0 deletions tests/test-cli/test-commands.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
})