Skip to content
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

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

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.

Copy link
Collaborator

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)

Copy link
Collaborator

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.

return nil
}

Expand Down