Files: a2cedde098e0580bb46ca8ac1946939cc48fac90 / src / cli.js
648 bytesRaw
1 | const ssbClient = require('ssb-client') |
2 | const ref = require('ssb-ref') |
3 | const argv = require('minimist')(process.argv) |
4 | const createServer = require('./server') |
5 | const SSBNews = require('.') |
6 | |
7 | ssbClient((err, sbot) => { |
8 | if (err) { |
9 | throw err |
10 | } |
11 | const news = new SSBNews(sbot) |
12 | |
13 | if (argv._[2] === 'server') { |
14 | createServer(sbot) |
15 | } else if (argv._[2] === 'story') { |
16 | if (ref.isMsg(argv._[3])) { |
17 | news.story(argv._[3], (err, story) => { |
18 | if (err) throw err |
19 | console.log(story) |
20 | sbot.close() |
21 | }) |
22 | } else { |
23 | throw new Error('story [id]') |
24 | } |
25 | } else { |
26 | throw new Error('unknown command') |
27 | } |
28 | }) |
29 |
Built with git-ssb-web