Skip to content

Commit

Permalink
cli: add LibraryStyle for helm output and add ✓ for success output
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhanushkodi committed Sep 16, 2021
1 parent fb58c46 commit 5f3b109
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cli/cmd/common/terminal/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ func (ui *basicUI) Output(msg string, raw ...interface{}) {
case WarningBoldStyle:
msg = colorWarningBold.Sprintf(" * %s", msg)
case SuccessStyle:
msg = colorSuccess.Sprintf(" + %s", msg)
msg = colorSuccess.Sprintf(" %s", msg)
case SuccessBoldStyle:
msg = colorSuccessBold.Sprintf(" + %s", msg)
msg = colorSuccessBold.Sprintf(" ✓ %s", msg)
case LibraryStyle:
msg = colorLibrary.Sprintf(" --> %s", msg)
case InfoStyle:
lines := strings.Split(msg, "\n")
for i, line := range lines {
Expand Down
9 changes: 9 additions & 0 deletions cli/cmd/common/terminal/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const (
WarningStyle = "warning"
WarningBoldStyle = "warning-bold"
InfoStyle = "info"
LibraryStyle = "library"
SuccessStyle = "success"
SuccessBoldStyle = "success-bold"
)
Expand Down Expand Up @@ -150,6 +151,13 @@ func WithSuccessStyle() Option {
}
}

// WithLibraryStyle styles the output as a success message.
func WithLibraryStyle() Option {
return func(c *config) {
c.Style = LibraryStyle
}
}

func WithStyle(style string) Option {
return func(c *config) {
c.Style = style
Expand All @@ -166,6 +174,7 @@ var (
colorInfo = color.New()
colorError = color.New(color.FgRed)
colorErrorBold = color.New(color.FgRed, color.Bold)
colorLibrary = color.New(color.FgCyan)
colorSuccess = color.New(color.FgGreen)
colorSuccessBold = color.New(color.FgGreen, color.Bold)
colorWarning = color.New(color.FgYellow)
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (c *Command) Run(args []string) int {
// Setup logger to stream Helm library logs
var uiLogger = func(s string, args ...interface{}) {
logMsg := fmt.Sprintf(s, args...)
c.UI.Output(logMsg, terminal.WithInfoStyle())
c.UI.Output(logMsg, terminal.WithLibraryStyle())
}

// Set up the kubernetes client to use for non Helm SDK calls to the Kubernetes API
Expand Down

0 comments on commit 5f3b109

Please sign in to comment.