-
Notifications
You must be signed in to change notification settings - Fork 253
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
introduced a test_and_capture method for backends #274
Conversation
@betesh I've also looked at this and had similar thoughts that it could be useful to be able to get the command stdout, stderr and success? from the capture or test methods. But I think it would be preferable to simply return the command object itself rather than extracting the Also, I'm not really in favour having a new on '1.example.com'
result = execute_command("whatever", raise_on_non_zero_exit: false, verbosity: Logger::DEBUG)
if result.full_stderr.strip == 'whatever'
# Do something
end
end
on '1.example.com'
if execute_command("whatever", test: true).full_stderr.strip == 'whatever'
# Do something
end
end What do you think? |
@robd The Command class wasn't written with direct user access in mind. It has almost no documentation, and exposes too many methods related to the execution of the command, whereas CapturedResult only has knowledge of the results of the command. I think taking your approach would require that we first improve documentation there, and make all methods private except what absolutely must be public, and may still necessitate separating the result and the execution into separate classes. Your approach would also sacrifice the convenience of the "strip" option, making the interface inconsistent with that of If you feel strongly that creating a new pollutes the interface too much, I would take your suggestion of
The only shortcoming I see in this example is that |
Hi Guys, please let me stop you, I can't see myself wanting to merge this, if a The argument about needing standard error is a fine one, and I actually can't tell you off the top of my head if I expect |
@betesh Just to follow up here, I agree that the I think that the The I think splitting the @leehambley What do you think about splitting the |
Can't speak for @leehambley but I +1 this |
Maybe slow and dangerous commands should have their logs simply redirected to a file, and incase the |
At the heart of all the things I do with SSHKit and Capistrano is questioning if there's more harm done by saying "this is an edge case which you can solve with a little workaround"… or that we gradually widen the API until it's so complex, our convenience wrapper, with pretty logging that we built around Net::SSH has become a monster with an API as-wide, but not-quite-the-same-as Net::SSH, and we've "improved" away all the things that made SSHKit fun and convenient to use. |
Totally in favour of that, I can imagine how you struggled in Airbrussh - but I don't think adding another |
So going forward, how should I approach a PR on this? By splitting Command and CommandResult and making |
I think that splitting Command, and CommandResult makes sense, nothing more. |
@leehambley The direction you've given me is vague. It does not leave me with confidence that if I redo this PR, trying to follow your instructions this time around, it will be merged. Clearly I have not persuaded you on the main goal of this PR, which is to give me a clean way to run a command once, and have |
Sometimes you need to capture STDERR, or to look back and see what happened if a command failed.