usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.67k stars 1.28k forks source link

[cli] Mode to print response to stdout #3111

Open CaptainQuirk opened 2 months ago

CaptainQuirk commented 2 months ago

I have checked the following:

Describe the feature you want to add

Hi there and thanks for the good work !

I was testing Bruno to see if it could replace the use of httpyac in a project where we use it as a wrapper for curl requests, supercharged with hook to handle authentication and the like.

I had expected the bru command to actually output the request result to stdout but I just realized that the cli was mostly thought of a test runner.

Would you consider just® printing the response to a request and optionally its headers to the terminal, without anything else ?

Mockups or Images of the feature

screen-bruno

berlingoqc commented 2 months ago

if you want to do send the stdout to /dev/null and pipe the bru run command to a cat of the output json file.

bru run INTEGRATION/ABORT/folder.bru -o test.json &> /dev/null; cat test.json | jq -r '.results[0]'
CaptainQuirk commented 2 months ago

Thanks for your quick answer !

I find this solution extremely complicated though and not really usable in the long run :

I think I'm rather looking for a new bru sub command that would handle one request only !

CaptainQuirk commented 2 months ago

What about a send subcommand that would be the cli equivalent of running the request in the GUI and that would print to stdout the content of the response body and headers ?

CaptainQuirk commented 2 months ago

Should this be part of a discussion ? I would be willing to work on such a subcommand, if this would be accepted as a feature for the community edition !

berlingoqc commented 2 months ago

i think it's fine there , you can raise a MR but don't get your hope up for it to get merge. But i think it will be easy to implement without affection the existing code so should be fine just need to use runSingleRequest

CaptainQuirk commented 2 months ago

Well, I'd rather put up some effort if only If I think it's bound to be merged at some point and this is where I would like to be sure that it would be accepted as a community feature.

Besides, I may create a certain level of code dupplication given what such a subcommand would have in command with run, regarding arguments for example.