forked from cabal-club/cabal-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·41 lines (29 loc) · 861 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
var Cabal = require('cabal-node')
var cabalSwarm = require('cabal-node/swarm.js')
var minimist = require('minimist')
var frontend = require('./neat-screen.js')
var args = minimist(process.argv.slice(2))
var homedir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE
var rootdir = homedir + '/.cabal/archives/'
var usage = `Usage
cabal --key dat://key
OR
cabal --db /path/to/db
Options:
--nick Your nickname.
Work in progress! Learn more at github.com/cabal-club
`
if (args.key) {
args.key = args.key.replace('dat://', '').replace(/\//g, '')
args.db = rootdir + args.key
}
if (!args.db) {
process.stderr.write(usage)
process.exit(1)
}
var cabal = Cabal(args.db, args.key, {username: args.nick || 'conspirator'})
cabal.db.on('ready', function () {
frontend(cabal)
cabalSwarm(cabal)
})