albertodeago / curl-generator

A small, dependency free library to get curl snippets
MIT License
20 stars 7 forks source link

Feature Request: Curl Options in Output #4

Closed shandygunawan closed 3 years ago

shandygunawan commented 3 years ago

Hi there! Nice work!

Thank you so much for making this. It's a life saver.

Though there are one problem that I encountered: There is seems no way to add curl options in the CurlGenerator so I have to add it manually by concatenating the string output.

So I think it would be nice to have one.

Once again, thank you so much for making this.

Cheers.

albertodeago commented 3 years ago

Hi @shandygunawan, thanks for the kind words!

Can you make some examples so I can think a bit more about it?

shandygunawan commented 3 years ago

Hello. Here are some examples I can think of:

const curlSnippet = CurlGenerator(params, {"silent": true, "show-error": true}) // curlSnippet => curl "https://jsonplaceholder.typicode.com/posts" -X POST -H "Content-type: application/json; charset=UTF-8" -d "{\"id\":\"123-456-789\",\"key1\":\"value 1\",\"key2\":\"a \\\"complex\\\" value\"}" -s -S

const curlSnippet = CurlGenerator(params, {"output": "output.txt" }) // curlSnippet => curl "https://jsonplaceholder.typicode.com/posts" -X POST -H "Content-type: application/json; charset=UTF-8" -d "{\"id\":\"123-456-789\",\"key1\":\"value 1\",\"key2\":\"a \\\"complex\\\" value\"}" -o output.txt

No need to support all of the options of course haha, maybe the most used ones.

albertodeago commented 3 years ago

Thanks for your time @shandygunawan. That looks like a nice addition, I'll check for options that sounds reasonable to have and add them.

albertodeago commented 3 years ago

Released with 0.2.0