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

Commit ef701dc

Browse files
committed
add bootstrap list to cli
1 parent f404a8f commit ef701dc

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

src/cli/commands/bootstrap/add.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../ipfs-core')
5+
const debug = require('debug')
6+
const log = debug('cli:version')
7+
log.error = debug('cli:version:error')
8+
9+
module.exports = Command.extend({
10+
desc: 'Shows IPFS version information',
11+
12+
options: {
13+
number: {
14+
alias: 'n',
15+
type: 'boolean',
16+
default: false
17+
},
18+
commit: {
19+
type: 'boolean',
20+
default: false
21+
},
22+
repo: {
23+
type: 'boolean',
24+
default: false
25+
}
26+
},
27+
28+
run: (name) => {
29+
var node = new IPFS()
30+
node.version((err, version) => {
31+
if (err) { return log.error(err) }
32+
33+
console.log(version)
34+
})
35+
}
36+
})

src/cli/commands/bootstrap/list.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../../ipfs-core')
5+
const debug = require('debug')
6+
const log = debug('cli:version')
7+
log.error = debug('cli:version:error')
8+
9+
module.exports = Command.extend({
10+
desc: 'Show peers in the bootstrap list',
11+
12+
options: {},
13+
14+
run: (name) => {
15+
var node = new IPFS()
16+
node.bootstrap.list((err, list) => {
17+
if (err) { return log.error(err) }
18+
list.forEach(node => { console.log(node) })
19+
})
20+
}
21+
})

src/cli/commands/bootstrap/rm.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../ipfs-core')
5+
const debug = require('debug')
6+
const log = debug('cli:version')
7+
log.error = debug('cli:version:error')
8+
9+
module.exports = Command.extend({
10+
desc: 'Shows IPFS version information',
11+
12+
options: {
13+
number: {
14+
alias: 'n',
15+
type: 'boolean',
16+
default: false
17+
},
18+
commit: {
19+
type: 'boolean',
20+
default: false
21+
},
22+
repo: {
23+
type: 'boolean',
24+
default: false
25+
}
26+
},
27+
28+
run: (name) => {
29+
var node = new IPFS()
30+
node.version((err, version) => {
31+
if (err) { return log.error(err) }
32+
33+
console.log(version)
34+
})
35+
}
36+
})

src/http-api/routes/bootstrap.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const server = require('./../index.js').server
4+
const resources = require('./../resources')
5+
6+
server.route({
7+
method: 'GET',
8+
path: '/api/v0/bootstrap',
9+
handler: resources.version.list
10+
})
11+
12+
server.route({
13+
method: 'POST',
14+
path: '/api/v0/boostrap',
15+
handler: resources.version.add
16+
})
17+
18+
server.route({
19+
method: 'DELETE',
20+
path: '/api/v0/boostrap',
21+
handler: resources.version.add
22+
})

0 commit comments

Comments
 (0)