-
Notifications
You must be signed in to change notification settings - Fork 78
/
bin.coffee
53 lines (47 loc) · 1.34 KB
/
bin.coffee
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
42
43
44
45
46
47
48
49
50
51
52
53
yargs = require 'yargs'
whois = require './index'
util = require 'util'
yargs.usage('$0 [options] address')
.default('s', null)
.alias('s', 'server')
.describe('s', 'whois server')
.default('f', 0)
.alias('f', 'follow')
.describe('f', 'number of times to follow redirects')
.default('t', 60000)
.alias('t', 'timeout')
.describe('t', 'socket timeout')
.default('p', null)
.alias('p', 'proxy')
.describe('p', 'SOCKS proxy')
.boolean('v')
.default('v', no)
.alias('v', 'verbose')
.describe('v', 'show verbose results')
.default('b', null)
.alias('b', 'bind')
.describe('b', 'bind to a local IP address')
.boolean('h')
.default('h', no)
.alias('h', 'help')
.describe('h', 'display this help message')
if yargs.argv.h
yargs.showHelp()
process.exit 0
if not yargs.argv._[0]?
yargs.showHelp()
process.exit 1
whois.lookup yargs.argv._[0], server: yargs.argv.server, follow: yargs.argv.follow, timeout: yargs.argv.timeout, proxy: yargs.argv.proxy, verbose: yargs.argv.verbose, bind: yargs.argv.bind, (err, data) =>
if err?
console.log err
process.exit 1
if util.isArray data
for part in data
if 'object' == typeof part.server
console.log part.server.host
else
console.log part.server
console.log part.data
console.log
else
console.log data