You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case, I have a captured variable name json (which itself was using Xpath and JSONpath to get some obscured JSON data from a webpage) and it's returning an array which I could then use for further scripting, particularly looping through. Needing to figure out this query is a bit of a usability negative, as I do think that there are many reasons one might want to use captured values outside of hurl.
Proposal
I suggest the additon of a -g, --get <VARIABLE> option (or something similar) that effectively just returns whatever using {{variable}} within a hurl script would have gotten at the end of the file. This significantly simplifies the tast of using captured data, and covers the case of wanting a variable from a prior entry before the end that hadn't had its value replaced (which is definitely possible using jq, but I imagine many users wouldn't want to go through the effort of writing it out if there was a simpler option..
As well, I think certain cases such as the data being a single, flat JSON array, could return the contents of the array rather than in JSON format unless --json is still specified. Multiple uses of -g could simply dump values to stdout as-is unless json output is desired, as well.
Additional context and resources
The sw.hurl file is as follows, in case that is helpful:
I agree, a simple way of getting captured variable is a good enhancement. I wonder if, for this use case, we could reuse/extend --write-out option from curl (see for instance #1745).
With curl:
$ curl -w "Server: %header{server}\n" http://example.com will output on stdout the "Server" response header.
We can implement this, plus extend it with Hurl specificity (variables):
$ hurl --write-out "foo %variable{bar}" file.hurl would output "foo" concatenated with the value of the variable ˋbar`
Oooh, that could be a pretty versatile solution. I'd honestly still argue for both ways of doing it, simply because a new user might struggle to find that --write-out option and learning even more additional syntax could be a bit of a pain.
Problem to solve
Currenty, the best way to get a captured value out of hurl to use for other shell scripting seems to be something like:
In this case, I have a captured variable name
json
(which itself was using Xpath and JSONpath to get some obscured JSON data from a webpage) and it's returning an array which I could then use for further scripting, particularly looping through. Needing to figure out this query is a bit of a usability negative, as I do think that there are many reasons one might want to use captured values outside of hurl.Proposal
I suggest the additon of a
-g, --get <VARIABLE>
option (or something similar) that effectively just returns whatever using{{variable}}
within a hurl script would have gotten at the end of the file. This significantly simplifies the tast of using captured data, and covers the case of wanting a variable from a prior entry before the end that hadn't had its value replaced (which is definitely possible usingjq
, but I imagine many users wouldn't want to go through the effort of writing it out if there was a simpler option..As well, I think certain cases such as the data being a single, flat JSON array, could return the contents of the array rather than in JSON format unless
--json
is still specified. Multiple uses of-g
could simply dump values to stdout as-is unless json output is desired, as well.Additional context and resources
The
sw.hurl
file is as follows, in case that is helpful:Tasks to complete
n/a
The text was updated successfully, but these errors were encountered: