-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored Process.run #382
Conversation
Damn, I didn't notice #379 earlier :/ |
Mmh, I actually like having a single unified interface for process spawning, that avoids having to learn a bunch of them which many have overlapping usecases. In Ruby I'm always not sure for a moment which one I should use, and I see a lot of people doing things like |
I thought the following choices do what the programmer most certainly expects:
I personaly like a bare-metal I'd also favor dropping support for |
@ysbaddaden If you and @jhass are sending pull requests for the same thing it only means it's time to celebrate: the community is growing! 😄🎉🎂🎈🎁 I'll review this with @waj today, if we have some time. There's a lot of functionality here, and I like it that it builds on top of other methods. And it doesn't segfault on travis :-) (but I'm almost sure the other PR segfaults because of a bug in Crystal, I still have to review that...) Merci beaucoup! |
I'm open for directions about Shall we strip I like that Open3 has different methods for the 3 most common use cases, thought I agree the different names can be confusing, and require documentation. We could merge |
To be honest, there was a |
I think making the top level functions abstractions with simple interfaces upon a more complex interface somewhere else is the way to go, there's no point in replicating a complex interface at the top level, if the convenience wrapper is not handling a usecase, one should just use the thing it wraps. |
@ysbaddaden @jhass We are still reviewing both pull requests. It's very hard to take a decision :-) We want to make the API very comfortable to use, simple and without redundancy. Of course this is hard because there's so many things you could want to do. There's for example this, which seems pretty confusing. I'm not sure why Ruby has so many ways to deal with this, I guess maybe it was an evolutionary process and they needed to keep backwards compatibility. @ysbaddaden We really like that you copied Ruby's semantic here, but we might try to do something different (we don't know what, yet). Another thing is that your So... patience :-) But let's use this space to discuss about the design we want, and all the possibilities we want to cover. |
Maybe I can have another PR with only
My moto is usually: don't bother reinventing the wheel if Ruby did. Yet I agree that:
|
@ysbaddaden Thank you for taking the time to do this. We finally did it in bbf2036 . Before this we looked at every pull request about this big issue and we combined all that knowledge into a single, unified interface. I'm sure there are a lot of thing to improve (for example |
I needed
Process.spawn
, which executes a command, but returns its pid and won't wait for it. I eventually refactored all ofProcess.run
, following the Ruby library (to some extent):I also implemented Open3, which helps to spawn processes with pipes and capture the output: