Open kareem-abdul opened 2 months ago
I was searching if it is possible to have a wrapper around this custom output, so that the plugin can maybe detect it in some way (maybe a treesitter token?). And it seems the following works
curl -s -w "\n<custom>%{time_total}\n%{time_redirect}</custom>" -XGET https://jsonplaceholder.typicode.com/todos
which results in the following output
[
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
},
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
}
]
<custom>1.147859
0.000000</custom>
Great idea, I did not know about this feature! I'll play around with it a little and see if I can come up with a nice solution.
Hi, Curls man page defines an option called
--write-out
which you can use to output in custom formats. Ussually, I use this feature to get the request/response times, debug ssl, redirects etc. The formats can be specified either inline in the command like thiscurl -w "%{total_time}" https://example.com
or in a different file like followingand use it in the command like so
curl -w "@curl-filename.txt"
Right now, it is somewhat possible to do this, as it is just a flag for curl. But the output looses its format. I assume that this is because of jq eg: you could do this request
This will give the results in a single line, with the custom format at the end of it
I think it would be great if the plugin had explicit support for this. That is, users can define a format file (or an inline format) in the config, or the plugin detects the
-w
flag in the curl file, and outputs the formatted result ,maybe in the top of the output buffer, just like how headers are shown for the-i
flag.