fix(cryptogen): write error output to stderr and use standard exit code#224
fix(cryptogen): write error output to stderr and use standard exit code#224abhayrajjais01 wants to merge 1 commit into
Conversation
Signed-off-by: abhayrajjais01 <abhayraj916146@gmail.com>
dc109e5 to
3e93b0d
Compare
|
Nice improvement outing errors to stderr and using a standard exit code makes the CLI behavior much more predictable, especially when used in scripts. |
It doesn’t try to simulate multiple independent error emissions in one invocation - today cryptogen still exits on the first fatal error returned to main(), so there is not really a batch of unrelated errors printed in sequence from that wrapper Thanks for suggestion |
|
The tool exits on the first fatal error, multiple error emission isn’t really applicable here. I like the idea of adding more table-driven subprocess cases or golden checks as a follow-up for stronger guarantees. Happy to see this evolve further 👍 |
Type of change
Description
cryptogenwrote command errors withfmt.Printf(stdout) and exited withos.Exit(-1), which wraps to255on POSIX shells. Errors should go to stderr and use a conventional non-zero exit (e.g.1) so pipelines and scripts behave predictably—similar to other tools in this repo.Changes:
tools/cryptogen/main.go-> emit errors viafmt.Fprintf(os.Stderr, ...)andos.Exit(1).tools/cryptogen/main_test.go-> TestExecutionErrorRoutedToStderrsubprocess test: malformed config - stderr contains the error line, stdout does not; exit status1`Additional details (Optional)
Suggested checks:
go test ./tools/cryptogen/go vet ./tools/cryptogen/