Skip to content

Commit

Permalink
Make output of krew search easier to read (kubernetes-sigs#253)
Browse files Browse the repository at this point in the history
So far, the last column was labelled with `STATUS` and had three options
(installed, available, unavailable). This was hard to read because
installed and available have the same length, and `unavailable` was not
specific.

Now, the column is labelled `INSTALLED` with values
yes/no/unavailable on <PLATFORM>
  • Loading branch information
corneliusweig authored and k8s-ci-robot committed Jul 12, 2019
1 parent 328fc71 commit fa7f844
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/krew/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Remarks:
}

func printTable(out io.Writer, columns []string, rows [][]string) error {
w := tabwriter.NewWriter(out, 0, 0, 1, ' ', 0)
w := tabwriter.NewWriter(out, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, strings.Join(columns, "\t"))
fmt.Fprintln(w)
for _, values := range rows {
Expand Down
9 changes: 5 additions & 4 deletions cmd/krew/cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cmd

import (
"os"
"runtime"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -73,18 +74,18 @@ Examples:
}

var rows [][]string
cols := []string{"NAME", "DESCRIPTION", "STATUS"}
cols := []string{"NAME", "DESCRIPTION", "INSTALLED"}
for _, name := range matchNames {
plugin := pluginMap[name]
var status string
if _, ok := installed[name]; ok {
status = "installed"
status = "yes"
} else if _, ok, err := plugin.Spec.GetMatchingPlatform(); err != nil {
return errors.Wrapf(err, "failed to get the matching platform for plugin %s", name)
} else if ok {
status = "available"
status = "no"
} else {
status = "unavailable"
status = "unavailable on " + runtime.GOOS
}
rows = append(rows, []string{name, limitString(plugin.Spec.ShortDescription, 50), status})
}
Expand Down

0 comments on commit fa7f844

Please sign in to comment.