forked from sergeyt/fogbugz.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.coffee
27 lines (22 loc) · 823 Bytes
/
test.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
argv = require('optimist').argv
Q = require('q')
fb = require('fogbugz')
methods = [
'filters', 'projects', 'areas', 'milestones',
'categories', 'priorities', 'people', 'search', 'events'
]
reserved = ['email', 'pwd', 'password', '_', '$0'].concat(methods)
printJson = (x) -> console.log(JSON.stringify(x, null, 2))
printError = (err) -> console.log(err)
printAll = (_) -> [].slice.call(arguments, 0).forEach(printJson)
p = fb
url: 'https://code.datadynamics.com',
email: argv.email,
password: argv.pwd || argv.password
p.fail printError
p.done (client) ->
console.log('token:%s', client.token)
m = methods.filter((m) -> argv.hasOwnProperty(m))[0]
argFilter = (k) -> reserved.indexOf(k) < 0
args = Object.keys(argv).filter(argFilter).map((k) -> argv[k])
client[m].apply(client, args).done(printAll)