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

Make plain-text spinner element avaialble via config #48

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

marcparadise
Copy link
Member

@marcparadise marcparadise commented Apr 3, 2018

This adds a PlainTextElement that has an interface like a TTY::Spinner
but provides update-per-line plain text output.

This is useful when debugging with pry while a spinner
is running; without it, the spinner refreshes interfere
with the IRB session.

To enable this, add the following to config.toml:

[dev]
spinner="PlainTextElement"

Output example:

…ts/chef-workstation$ be chef target converge winrm://user:password@192.168.1.204 user user1
[ - ] [192.168.1.204] Connecting...
[ - ] [192.168.1.204] Connected.
[ - ] [192.168.1.204] Verifying Chef client installation.
[ - ] [192.168.1.204] Downloading Chef client installer.
[ - ] [192.168.1.204] Uploading Chef client installer.
[ - ] [192.168.1.204] Installing Chef client.
[ - ] [192.168.1.204] Chef client installation completed!
[ - ] [192.168.1.204] Converging user[user1]...
[ - ] [192.168.1.204] Successfully converged user[user1]!

Signed-off-by: Marc A. Paradise marc.paradise@gmail.com

This adds a PlainTextElement that has an interface like a TTY::Spinner
but provides update-per-line plain text output.

This is useful when debugging with pry while a spinner
is running; without it, the spinner refreshes interfere
with the IRB session.

To enable this, add the following to config.toml:

[dev]
spinner="PlainTextElement"

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
@marcparadise marcparadise requested a review from a team April 3, 2018 16:52
params.each_pair do |k, v|
msg.gsub!(/:#{k}/, v)
end
ChefWorkstation::Log.send(log_method, msg)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I found this useful, but I'm thinking we should put it in StatusUpdater instead so that it's the default behavior regardless of the UI element in use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, agreed - I think it should go in StatusUpdater if we have it anywhere.

My future vision is that if you passed the equivalent of --force-logger to the CLI, the spinner logic would be disabled completely and you would just get traditional log output on STDOUT. So in that case I think StatusUpdater handling it makes more sense. But we can definitely leave this here for now

Copy link
Contributor

Choose a reason for hiding this comment

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

agree

Copy link
Contributor

@tyler-ball tyler-ball left a comment

Choose a reason for hiding this comment

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

This has definitely bugged me many times before - thanks for introducing a fix!

params.each_pair do |k, v|
msg.gsub!(/:#{k}/, v)
end
ChefWorkstation::Log.send(log_method, msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, agreed - I think it should go in StatusUpdater if we have it anywhere.

My future vision is that if you passed the equivalent of --force-logger to the CLI, the spinner logic would be disabled completely and you would just get traditional log output on STDOUT. So in that case I think StatusUpdater handling it makes more sense. But we can definitely leave this here for now

Copy link
Contributor

@jonsmorrow jonsmorrow left a comment

Choose a reason for hiding this comment

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

LGTM!

params.each_pair do |k, v|
msg.gsub!(/:#{k}/, v)
end
ChefWorkstation::Log.send(log_method, msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

agree

@marcparadise marcparadise merged commit 07d2669 into master Apr 3, 2018
@chef-ci chef-ci deleted the mp/add-configurable-spinner-element branch April 3, 2018 22:04
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.

3 participants