Code Monkey home page Code Monkey logo

Comments (8)

jonaslu avatar jonaslu commented on May 23, 2024 1

Hi again!

I agree with this. Output from the backend can even intermingle, so separating them solves that too: https://unix.stackexchange.com/questions/476080/what-prevents-stdout-stderr-from-interleaving

For the delay: I'm in the middle of a major overhaul of the internals and wanted to see what impact it had, but it looks like doing this won't collide that much so go ahead and do the PR.

from ain.

jonaslu avatar jonaslu commented on May 23, 2024

Thanks for reporting! I'll have a think of the impact of changing the behaviour (which was a conscious decision to capture all output in the order the backend prints it): https://github.com/jonaslu/ain/blob/main/internal/pkg/call/curl.go#L89

In the meantime, you can work around this by doing:

Host]
http://localhost:3000/places

[Headers]
Content-Type: application/json

[Backend]
curl

[BackendOptions]
-sS -D /proc/${PID}/fd/2

PID=$$ ain the_code_provided.ain

That will print headers to the shells stderr and output to stdout

from ain.

erikeah avatar erikeah commented on May 23, 2024

Thanks a lot for quick response! Once you have decided what to do let me know and may I can submit PR.

from ain.

erikeah avatar erikeah commented on May 23, 2024

Great! Then once I have the code, I will open PR!

from ain.

erikeah avatar erikeah commented on May 23, 2024

Hi Jonas, today I had a bit of time and I did the task as you can see in my fork, however I find that I have introduced a lot of boiler plate on the runAsCmd functions.

What do you think if I create a new function share for all backends to run the command and contain the boiler plate?

Pseudo-code based on my fork (internal/pkg/call/call.go):

func CallBackend(ctx context.Context, callData *data.Call, leaveTmpFile, printCommand bool) (Output, error) {
       ...

	if printCommand {
		if command, err := backend.getAsString(); err != nil {
			return Output{StdErr: []byte(command)}, err
		} else {
			return Output{StdOut: []byte(command)}, nil
		}
	}

	cmd, err := backend.GetCmd(backendTimeoutContext) // May returns the exec.CommandContext
        output, err := runCmd(cmd)

        ...
	return output, nil
}

from ain.

jonaslu avatar jonaslu commented on May 23, 2024

Hard to tell, better if you do it as a commit on top of your fork and we can look at it then. There's always git reset.

from ain.

erikeah avatar erikeah commented on May 23, 2024

I will give a try this weekend then.

from ain.

jonaslu avatar jonaslu commented on May 23, 2024

Fixed in commit eb9fa6c, closing this

from ain.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.