-
Notifications
You must be signed in to change notification settings - Fork 31
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
plan: pretty-printing terminal output #22
Conversation
4066b59
to
28cb6bb
Compare
I'm having some trouble with godep... I can't make it save to |
|
||
"github.com/Sirupsen/logrus" | ||
"github.com/asteris-llc/converge/exec" | ||
"github.com/asteris-llc/converge/load" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var nocolor bool |
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.
please find a way to do this without introducing a global variable. We'll need this in more than one place. (hint: viper)
For the vendoring issue, what version of Go are you using? It should be 1.6+ and with the latest version of |
Also, could you attach a screenshot of the colored and plain output, please? |
28cb6bb
to
17fc025
Compare
@BrianHicks Ah, it was my version of Godep. Still not working, though :/
|
@@ -25,6 +26,8 @@ import ( | |||
"github.com/spf13/viper" | |||
) | |||
|
|||
var nocolor bool |
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.
this is still hangin' out here unused
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.
hah! Thanks :)
just thinking about future extensibility here: I know we're going to have type PrettyPrinter interface {
fmt.Stringer
Pretty() string
} |
@BrianHicks What do you think the |
https://github.com/asteris-llc/converge/blob/master/exec/apply.go#L26-L31 but they don't need to have similar fields, they just need to be able to pretty print. You could do it with any list of objects. I actually think we're going to have to have a stream of objects instead for quicker feedback, though. |
Okay, I've implemented a (note that while those Let me know what you think! |
I'd like to see a blank line between each set, but otherwise that looks good. :) |
} | ||
|
||
// condFmt returns a function that only formats its input if a condition is true. | ||
func condFmt(cond bool, format func(interface{}) string) func(interface{}) string { |
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.
this is used in both, so it belongs in a utility package. exec/utils.go
springs to mind.
So in a29f8cb24f9b6a314b6ae1776372fa217eed8802, I attempted to add a newline between each |
41d9a32
to
c1575c5
Compare
Just to close the loop on my "streaming output" comment earlier, there is now streaming status. The list interface should be unaffected. :) |
tmplStr += `Status: "{{blueOrYellow (trimNewline .OldStatus)}}" ` | ||
tmplStr += `=> "{{blueOrYellow (trimNewline .NewStatus)}}"` | ||
tmplStr += "\n\tSuccess: {{redOrGreen .Success}}" | ||
tmplStr := `{{plusOrMinus}}{{redOrGreen .Path}}: |
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.
space here, please. {{plusOrMinus}} {{redOrGreen .Path}}
moves plusOrMinus to a utility function
I'll let you rewrite to use that utility function, it's merged :) When that's done, we'll merge this, looks good. Thanks for all your effort! |
There's only one problem! That utility function is now in |
|
||
// Print implements a pretty printer that uses ANSI terminal colors when a color | ||
// terminal is available. | ||
func (rs Results) Print() string { |
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.
@siddharthist regarding your comment: how about Print(color bool)
? This is not the place to determine that anyway.
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.
Sure!
@BrianHicks this is ready for review |
plan: pretty-printing terminal output
Will detect (just like logrus) if there is a color terminal available. Can be manually disabled. Colors can easily be changed, but for now they are:
fixes #12