Repository navigation
fix(cli): return correct exit codes and report errors on stderr - #18
Merged
Merged
Conversation
- Use RunE on every command and let Execute report the error once. - Pass the exit status of docker compose and wp-cli through unchanged. - Print other errors on stderr with a non-zero exit status. - Remove the color.Red printf misuse that printed %!(EXTRA ...). - Show success messages only after success. - sites start/stop/restart continue after a failed site and report every failed site. - Add a fake docker test harness and end-to-end tests. Closes #2
sites restart printed 'site: exit status 1' twice when a site failed to stop and then to start. Each failure now starts with its phase: 'stopping site: …' or 'starting site: …'. Part of #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
RunE.Executeshows the error one time and sets the exit status.docker composeor wp-cli fails,flyexits with the same status and shows no more text. For example,wp plugin is-installedkeeps its exit status.Error: …with exit status 1. Usage errors also showRun 'fly <command> --help' for usage.color.Red("…:", err)calls. They showed%!(EXTRA …).sites start,sites stopandsites restartcontinue after a failed site. At the end, they show each failed site. One function replaces the two copies of this code.stopping example.com: exit status 1. Thussites restartshows two different lines when a site fails to stop and then fails to start.fly execwithout arguments andfly updatewithout root give exit status 1.internal/testutiladds a fakedockerscript for tests.main_test.gobuildsflyand runs it end to end.Behavior change
flynow get a correct exit status. Before this change, most failures gave exit status 0.Tests
exitCode,forEachSite, andsites restartwith a site that fails in the two phases.docker:flyexit status of 7.fly exec -- php sh -c 'exit 7'exits with status 7.Closes #2