bruno icon indicating copy to clipboard operation
bruno copied to clipboard

[Feature Request] Prompt for input a variable

Open paulo-dc opened this issue 1 year ago • 5 comments

Is it possible to add to possibility to have a "prompt variable" ?

It's just for convienience to be able to set a variable à the request execution. For example, we could have such request :

GET : {{base_url}}/myapi/v1/mystuff/users/{{$prompt userId}}/details

And so, instead of copy/paste an id directly in the url form before the request run, we would be able to simply execute the request without modifying it, and a pop up would appear letting us set the id to replace the {{$prompt userId}} field.

Such feature exists at the moment in Insomnia. It would be very cool to have this in bruno.

paulo-dc avatar Nov 23 '23 09:11 paulo-dc

I have a handful of investigative and "repair" queries that I sometimes need to run with the Id of a specific user, for example. Which user I run the query or mutation for will never be the same twice, but I don't want to end up hard-coding the Id directly in the query. For the moment, I just have to remember to replace the Id with something bogus before saving the query for next time, but it would be a far better experience if I were prompted for the values each time I run the query. Ideally, the pop-up would remember the last value used, at least for the current session, so that I don't have to keep pasting it in each time. If I were to close the tab, the value should be forgotten, though, so I don't accidentally use the same value the next time I have to do a similar investigation.

I'd be fine if there were simply a way to mark a property on the Variables tab as being transient, perhaps the "{{$" syntax suggested above. I could specify my value directly on the Variables tab, just as long as I know that when I save the query, that value will get dropped from the file or something. Whatever is easiest. I just don't want that Id to make it into the file permanently, that's all.

MelGrubb avatar Dec 15 '23 12:12 MelGrubb

This is really usefull so I could change values in query and body and it does not get carry on to other user and to my git

LuccaRomanelli avatar Dec 18 '23 17:12 LuccaRomanelli

Likewise, I have a lot of API requests to investigate and the IDs are always different. If the env variable is not set, there could be an option to prompt for the value.

simongodard avatar Jan 23 '24 14:01 simongodard

I would suggest adding a script method for that like bru.prompt('varName', default, prompt) so you can initialize a var in a pre script. If that is something that's seen as useful I could imagine trying my hand on such a functionality

koljatm-edeka avatar Feb 05 '24 08:02 koljatm-edeka

image Added a possible implementation of this feature. Open to suggestions.

KoljaTM avatar Feb 09 '24 10:02 KoljaTM