forked from dat-ecosystem/dat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·36 lines (31 loc) · 875 Bytes
/
cli.js
File metadata and controls
executable file
·36 lines (31 loc) · 875 Bytes
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
#!/usr/bin/env node
var args = require('minimist')(process.argv.splice(2), {
alias: {p: 'port', q: 'quiet', v: 'version', s: 'static', r: 'resume'},
boolean: ['color', 'static', 'quiet', 'version'],
default: {color: true}
})
process.title = 'dat'
// set debug before requiring other modules
if (args.debug) {
var debug = args.debug
if (typeof args.debug === 'boolean') debug = '*' // default
process.env.DEBUG = debug
}
if (args.version) {
var pkg = require('./package.json')
console.log(pkg.version)
process.exit(0)
}
if (args.doctor) {
require('./bin/doctor')(args)
} else if (args._[0] === 'share') {
require('./bin/share')(args)
} else if (args._[0] && isDatLink(args._[0])) {
require('./bin/download')(args)
} else {
require('./usage')('root.txt')
}
function isDatLink (val) {
// TODO: support dat.land link
return val.length === 64
}