-
Notifications
You must be signed in to change notification settings - Fork 224
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
Fix versionFlag to output to stdout #710
Conversation
cli/main.go
Outdated
@@ -55,7 +55,7 @@ func Main() { | |||
func start(_ context.Context, cmd *cli.Command) error { | |||
// Only print the version if the flag is set | |||
if cmd.IsSet(versionFlag.Name) { | |||
log.Infof("mev-boost %s\n", config.Version) | |||
fmt.Printf("mev-boost %s\n", config.Version) //nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to do the setupLogging
step first, which sets it to stdout, and keep using log.Infof
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using fmt.Printf
here is the right thing actually. Otherwise, the output is difficult to parse:
$ ./mev-boost --version
INFO[2025-01-31T08:45:58.966-06:00] starting mev-boost version=3c51355-dev
INFO[2025-01-31T08:45:58.966-06:00] mev-boost 3c51355-dev version=3c51355-dev
And this would break EthPillar's regex here:
MB=$(if [[ -f /etc/systemd/system/mevboost.service ]]; then printf "Mev-boost: $(mev-boost --version | sed 's/.*\s\([0-9]*\.[0-9]*\).*/\1/')"; else printf "Mev-boost: Not Installed"; fi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR to do this instead:
fmt.Fprintf(cmd.Writer, "mev-boost %s\n", config.Version)
I believe this is most appropriate for CLI apps. Doesn't require //nolint
either.
Thanks @coincashew! I'm going to merge this now. |
📝 Summary
Rollsback a change which affected the versionFlag output
mev-boost --version
outputs to stdout once again.
Version output is currently outputting to stderr.
⛱ Motivation and Context
Fixes coincashew/EthPillar#47
Before
After