node-js-libs / curlrequest

A cURL wrapper
MIT License
184 stars 44 forks source link

output cURL statement instead of executing #6

Closed weisjohn closed 11 years ago

weisjohn commented 11 years ago

First off, thanks for making this, saved my day.

It may be a long shot, but I needed this functionality and thought you may want it as well. Basically, I needed to be able to put a helpful statement in the logs / give a statement to our QA team if a request in our server failed.

(I've introduced a dependency to underscore, not sure if that makes it a no-go. If you'd like to see this land but don't want to clean it up, I'd be happy to do so, just let me know what I could do to help land it).

I also added a repl so that I could easily debug it while working on it. I can take that repl out and resubmit if you'd like that as well.

Thanks again!

chriso commented 11 years ago

I actually thought that the callback received the command that was executed as the third argument but it turns out it wasn't working correctly. I've fixed this in 0.3.6 and also added a pretend option which skips making the actual request.

var curl = require('curlrequest');

curl.request({ url: 'http://google.com', pretend: true }, function (err, stdout, meta) {
    console.log('Executed "%s %s" in %s ms', meta.cmd, meta.args.join(' '), meta.time);
});

Let me know if this is what you're after

weisjohn commented 11 years ago

That is great! Thanks!