Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: avoid calling os.Exit directly
In https://cuelang.org/cl/552733 I improved and simplified the way that we use Cobra, primarily to make New do less work upfront. One aspect of the old design that I left behind, with some TODOs, is that some commands still called os.Exit(1) directly. This is unnecessary, as command functions return an error, as well as problematic, as exiting prevents running any more code such as writing to a CUE_STATS file or any deferred function calls. Thankfully, the "root" command does the right thing now, and a sub-command can signal an os.Exit(1) by returning ErrPrintedError. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I0627a9660433ba3259de921efafe0617d107faa8 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1192972 Reviewed-by: Roger Peppe <rogpeppe@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
- Loading branch information
Showing
6 changed files
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,6 +328,6 @@ type panicError struct { | |
Err error | ||
} | ||
|
||
func exit() { | ||
func panicExit() { | ||
panic(panicError{ErrPrintedError}) | ||
} |
This file contains 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