-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carlos Romero Brox
committed
Jun 3, 2013
1 parent
3e77609
commit 6d41c0e
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
var program = require('commander'), | ||
This comment has been minimized.
Sorry, something went wrong. |
||
request = require('request'), | ||
util = require('util'), | ||
i, | ||
url, | ||
trans; | ||
|
||
program | ||
.version('0.0.1') | ||
.option('-H, --host [hostname]', 'host, \'localhost\' by default', 'localhost') | ||
.option('-P, --port [number]', 'port, 5001 by default', 5001, parseInt) | ||
.option('-Q, --queue [id]', 'queue', "Q1") | ||
.option('-T, --trans [list]', 'list of transactions separated by comma', list) | ||
.option('-X, --secure', 'use HTTPS', false) | ||
.parse(process.argv); | ||
url = util.format('%s://%s:%d/queue/%s/ack', program.secure?'https':'http', program.host, program.port, program.queue); | ||
trans = { | ||
'transactions': program.trans | ||
}; | ||
|
||
console.log('url\n', url); | ||
console.log('trans\n', trans); | ||
request.post({url : url, json: trans}, function(err, res, body) { | ||
if(err) { | ||
console.log('error\n', err); | ||
} | ||
else { | ||
console.log('statusCode\n', res.statusCode); | ||
console.log('headers\n', res.headers); | ||
console.log('body\n', body); | ||
} | ||
}); | ||
function range(val) { | ||
return val.split('..').map(Number); | ||
} | ||
function list(val) { | ||
return val.split(','); | ||
} |
commander
should be added topackage.json