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

Add swarm disconnect cli #640

Merged
merged 1 commit into from
Dec 6, 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
15 changes: 13 additions & 2 deletions src/cli/commands/swarm/disconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@ log.error = debug('cli:object:error')
module.exports = {
command: 'disconnect <address>',

describe: '',
describe: 'Close connection to a given address',

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) => {
if (err) {
throw err
}
// TODO

ipfs.swarm.disconnect(argv.address, (err, res) => {
if (err) {
throw err
}

console.log(res.Strings[0])
})
})
}
}
8 changes: 8 additions & 0 deletions test/cli/test-swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ describe('swarm', function () {
expect(out).to.have.length.above(0)
})
})

it('disconnect', () => {
return ipfs('swarm', 'disconnect', nodeAddr).then((out) => {
expect(out).to.be.eql(
`disconnect ${nodeAddr} success`
)
})
})
})
})