git ssb

0+

cryptop / multiblob



forked from Dominic / multiblob

Tree: 3181c169ab56c583d978baa6d19e2c34530706fb

Files: 3181c169ab56c583d978baa6d19e2c34530706fb / bin.js

860 bytesRaw
1#! /usr/bin/env node
2
3var path = require('path')
4var Blobs = require('./')
5var pull = require('pull-stream')
6var toPull = require('stream-to-pull-stream')
7
8var cmd = process.argv[2], arg = process.argv[3]
9
10var dir = path.join(process.env.HOME, 'tmp', 'multiblob')
11
12var blobs = Blobs(dir)
13
14if(cmd === 'add')
15 pull(
16 toPull.source(process.stdin),
17 blobs.add(arg, function (err, hash) {
18 if(err) throw err
19 console.log(hash)
20 })
21 )
22
23if(cmd === 'get')
24 pull(blobs.get(arg), toPull.sink(process.stdout))
25
26if(cmd === 'has')
27 blobs.has(arg, function (err) {
28 if(err) throw err
29 console.error('okay')
30 })
31
32if(cmd === 'ls' || cmd === 'list')
33 pull(blobs.ls(), pull.drain(console.log))
34
35if(cmd === 'hash')
36 pull(toPull.source(process.stdin), createHash(console.log), pull.drain())
37
38if(cmd === 'resolve')
39 console.log(blobs.resolve(arg))
40

Built with git-ssb-web