hurl icon indicating copy to clipboard operation
hurl copied to clipboard

REPL

Open jcampbell05 opened this issue 1 year ago • 2 comments

Problem to solve

It can be very annoying to have to make a temp file just to use HURL, this is one area in which curl is better. Ideally we could have a REPL where we can type a request and then hit enter twice to make it send that request.

Proposal

When typing hurl --repl we get a CLI interface that lets you write out your hurl file similar to python's repl, after hitting enter twice hurl will treat this as a signal to say the file is done.

After the request completes the repl should load back in the last request's hurl file so it can be adjusted.

Additional context and resources

Tasks to complete

  • [ ] Introduce repl interface
  • [ ] Documentation

jcampbell05 avatar Oct 04 '24 08:10 jcampbell05

Hi @jcampbell05, you can already use Hurl without creating a file by using the standard input.

$ echo GET https://google.com | hurl
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
$ cat <<END | hurl --very-verbose
POST http://example.com
{ "message": "hello" }
END

A REPL could indeed be a nice feature, but to be honest, far from being priorized.

fabricereix avatar Oct 07 '24 18:10 fabricereix

I also find a REPL very attractive (maybe better at our current --interactive option which I doubt is used a lot). The thing that I'm a little worried is that a REPL would add a very different path code. So if there is a strong momentum on this issue / needs, why not.

jcamiel avatar Oct 09 '24 16:10 jcamiel

At least, it would be nice if perhaps hurl could try to read from stdin not only from a pipe (https://github.com/Orange-OpenSource/hurl/blob/master/packages/hurl_core/src/input.rs).

We could have this repl being the default when you just run hurl without any argument.

Or perhaps, if I run hurl 'GET https://www.wikipedia.org', hurl tries as a file just like today, and if the file does not exist, log it as a warning, and then tries to run the string as if it were a file content/stdin, and then fail at the end if it's not a valid format.

Jiehong avatar Nov 20 '24 10:11 Jiehong