Closed gurgeous closed 8 years ago
Thanks, that's great feedback!
Few initial thoughts:
exec
, system
and open3
Ruby commands. This means execution in new process environment that isolates the command from side effects. Which also gets all the environment variables and options passed down.cmd.execute("ls -la > output")
it will respect the redirect and execute directly the string. There are many ways to pass the arguments which try to mimic the spawn behaviour.cmd.ls "-la"
and the command just do what is intended. Agree it won't work in a lot of cases given complex arguments or executables but it is a nice Ruby-like way to run simple stuff if someone needs to.:group
option is tricky to escape as part of larger command and if the tested code can do it for you so much better. The :env
does quite few things for you including transformation of symbols into proper environment variables. Again, I think if the library can provide value in constructing these I think it should, especially when user can focus on writing Ruby?execute
vs run
, we can defo come back to this point once we clear up all the other issues.On another note, it would be great to open up separate issues for each bullet point. Then we are able to reference commits against features. I should be able to find some time tomorrow.
I've moved all the feedback to separate issues.
This is neat! Some quick thoughts after a few minutes of poking around. I really like it, so please don't take any of this feedback as negative. It's much easier to list the stuff that stood out rather than comment on the overall package, which is excellent. Thanks for putting this together!
cmd.execute("sudo apt-get install xyz > /tmp/output.txt")
instead of:cmd.execute(:sudo, "apt-get", "install", ...)
This is the most common use case, in my opinion, and supporting this pattern will encourage people to stop using bash to write this stuff.cmd.execute(:ls, "hello world")
execute!
, sadly.with exit status 0 (successful)
and only log failures. That will make them stand out more, I think. Or at least makesuccessful
use the same color as the rest of the line.env:
(this can easily be handled withENV
) -- chdir (easily handled with Dir.chdir("x") { ... } -- redirection (typically in the command, not needed in ruby land) -- :user/:group/:umask (that's what sudo is for)execute
torun
? I love brevity and there will never be a chance to change it after this! :)Here's a typical example, one of hundreds that I have from my old startup. Think about this snippet - would it make sense to separate out every argument? Would it make sense for the script to continue after failure? Would it make sense to replace shell redirects/pipes with a custom syntax? Just some food for thought.
Happy to help implement any/all changes... Thanks again!