Files: 3181c169ab56c583d978baa6d19e2c34530706fb / bin.js
860 bytesRaw
1 | |
2 | |
3 | var path = require('path') |
4 | var Blobs = require('./') |
5 | var pull = require('pull-stream') |
6 | var toPull = require('stream-to-pull-stream') |
7 | |
8 | var cmd = process.argv[2], arg = process.argv[3] |
9 | |
10 | var dir = path.join(process.env.HOME, 'tmp', 'multiblob') |
11 | |
12 | var blobs = Blobs(dir) |
13 | |
14 | if(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 | |
23 | if(cmd === 'get') |
24 | pull(blobs.get(arg), toPull.sink(process.stdout)) |
25 | |
26 | if(cmd === 'has') |
27 | blobs.has(arg, function (err) { |
28 | if(err) throw err |
29 | console.error('okay') |
30 | }) |
31 | |
32 | if(cmd === 'ls' || cmd === 'list') |
33 | pull(blobs.ls(), pull.drain(console.log)) |
34 | |
35 | if(cmd === 'hash') |
36 | pull(toPull.source(process.stdin), createHash(console.log), pull.drain()) |
37 | |
38 | if(cmd === 'resolve') |
39 | console.log(blobs.resolve(arg)) |
40 |
Built with git-ssb-web