Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI : Flag to print only curl output #2025

Open
arvindh123 opened this issue Oct 19, 2023 · 0 comments · May be fixed by #2242
Open

CLI : Flag to print only curl output #2025

arvindh123 opened this issue Oct 19, 2023 · 0 comments · May be fixed by #2242
Assignees
Milestone

Comments

@arvindh123
Copy link
Contributor

arvindh123 commented Oct 19, 2023

In CLI adding flag to print only curl output will be useful for :

  • Helps to visualize the request send by CLI /SDK , It will be useful for debugging CLI / SDK
  • User to see the actual request sent by CLI as cURL command
$ magistrala-cli things get all $token --curl

curl --location 'http://localhost/things' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer $token'

Following library helps to convert http request to cURL command

https://github.com/moul/http2curl

import (
    "http"
    "moul.io/http2curl"
)

data := bytes.NewBufferString(`{"hello":"world","answer":42}`)
req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", data)
req.Header.Set("Content-Type", "application/json")

command, _ := http2curl.GetCurlCommand(req)
fmt.Println(command)
// Output: curl -X PUT -d "{\"hello\":\"world\",\"answer\":42}" -H "Content-Type: application/json" http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu
@arvindh123 arvindh123 changed the title mainflux CLI : Flag to print only curl output CLI : Flag to print only curl output Oct 19, 2023
@dborovcanin dborovcanin transferred this issue from absmach/magistrala-old Jan 10, 2024
@dborovcanin dborovcanin added this to the S5 milestone May 15, 2024
@JeffMboya JeffMboya linked a pull request May 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants