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

Print all non-success output to STDERR #84

Merged
merged 3 commits into from
Aug 12, 2020

Conversation

austb
Copy link
Contributor

@austb austb commented Aug 10, 2020

Status

Ready for Review

Description

This tries to move all puts output to STDERR, except if it's the successful output of a command. It was done almost entirely via search and replace so it could use a three-quarter to full-hearted review.

Todos

  • Tests

Reviewers

@puppetlabs/dio
@highb
@briancain

@austb austb requested review from briancain, highb and a team as code owners August 10, 2020 23:02
@austb
Copy link
Contributor Author

austb commented Aug 10, 2020

Copying from Slack,

The motivation behind this is that I have a few scripts that either

floaty get <platform> --json | jq <filter>

to get the hostname to run bolt against

or > redirect it to a file for later consumption by me or the script

Copy link
Contributor

@briancain briancain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there 👋 thanks for the updates.

Generally, I think it's good to unify the output for vmfloaty to be consistent when printing messages for success or failure. However I think just putting STDOUT or STDERR in front of puts will make this easy for future contributors to make a mistake and not be explicit. For that reason, I think it would make more sense to add a small message printer class and stop using puts all together (which is kind of an anti-pattern to use just puts for CLI tools anyway, I think).

lib/vmfloaty.rb Outdated Show resolved Hide resolved
This adds the Logger class for log output, all of which goes to STDERR,
and uses puts to send only the command result to STDOUT.
Copy link
Contributor

@briancain briancain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!! Thanks for all the updates, this looks better 😄 Just a small piece of feedback. I haven't given this the full test on my machine since I don't really have access to vmpooler, so if someone wanted to try that, that would be awesome!

lib/vmfloaty.rb Outdated Show resolved Hide resolved
This moves the instance of the logger class to a class variable in the
`FloatyLogger` class and provides three class methods to log with in the
rest of the project `FloatyLogger.info`, `FloatyLogger.warn`, and
`FloatyLogger.error`.
Copy link
Contributor

@briancain briancain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making all those changes! :) looks good to me from a code perspective 👍

@mattkirby mattkirby merged commit 3b91d6f into puppetlabs:master Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants