elasticpath / epcc-cli

MIT License
35 stars 1 forks source link

`logs curl-replay N` command support #117

Open steve-r-west opened 2 years ago

steve-r-west commented 2 years ago

In #79 we added support for showing the list of HTTP requests. In #116 we sanitized a lot of them. We should let users generate a curl command to replay a request.

Acceptance Criteria

  1. When you run the the logs curl-reply N command, if an Nth command exists, a curl call is outputted that should replay the command.
    • The Bearer token should be replaced with a nested curl and jq command that generates a new token based on the environment variable values.
  2. The HTTP Header, method, and body should be identical to what was logged.

:bulb: You can ask Steve for some example code he has to convert an HTTP request into a curl command.

steve-r-west commented 2 years ago

An example might be if the first command is POST /v2/customers then the output of logs curl-replay 1 should be:

curl -X POST "https://api.moltin.com/v2/customers" \
-H "Authorization: Bearer $(curl https://api.moltin.com/oauth/access_token -d ... | jq .)"
-H "Content-Type: application/json"
-d '{data:{"name":"Ron Swanson", "email":"ron@swanson.com"}}'

Though this is incomplete.