Skip to content

Commit

Permalink
feat(cli): display status message in table when running glasskube list
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshal101 authored and hanshal101 committed Jul 2, 2024
1 parent 08bf0bd commit c36ac48
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cmd/glasskube/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListCmdOptions struct {
ListOutdatedOnly bool
ShowDescription bool
ShowLatestVersion bool
ShowMessage bool
More bool
OutputOptions
KindOptions
Expand Down Expand Up @@ -49,6 +50,7 @@ var listCmd = &cobra.Command{
if listCmdOptions.More {
listCmdOptions.ShowLatestVersion = true
listCmdOptions.ShowDescription = true
listCmdOptions.ShowMessage = true
}
lister := list.NewListerWithRepoCache(ctx)
var clPkgs []*list.PackageWithStatus
Expand Down Expand Up @@ -95,6 +97,8 @@ func init() {
"show the (cluster-)package description")
listCmd.PersistentFlags().BoolVar(&listCmdOptions.ShowLatestVersion, "show-latest", false,
"show the latest version of (cluster-)packages if available")
listCmd.PersistentFlags().BoolVar(&listCmdOptions.ShowMessage, "show-message", false,
"show the messages of (cluster-)packages")
listCmd.PersistentFlags().BoolVarP(&listCmdOptions.More, "more", "m", false,
"show additional information about (cluster-)packages (like --show-description --show-latest)")
listCmdOptions.OutputOptions.AddFlagsToCommand(listCmd)
Expand Down Expand Up @@ -137,9 +141,10 @@ func printClusterPackageTable(packages []*list.PackageWithStatus) {
if listCmdOptions.ShowDescription {
header = append(header, "DESCRIPTION")
}

header = append(header, "STATUS")
header = append(header, "MESSAGE")
if listCmdOptions.ShowMessage {
header = append(header, "Message")
}

err := cliutils.PrintTable(os.Stdout,
packages,
Expand Down Expand Up @@ -167,7 +172,9 @@ func printClusterPackageTable(packages []*list.PackageWithStatus) {
row = append(row, pkg.ShortDescription)
}
row = append(row, statusString(*pkg))
row = append(row, messageString(*pkg))
if listCmdOptions.ShowMessage {
row = append(row, messageString(*pkg))
}
return row
})
if err != nil {
Expand All @@ -186,7 +193,9 @@ func printPackageTable(packages []*list.PackagesWithStatus) {
header = append(header, "DESCRIPTION")
}
header = append(header, "STATUS")
header = append(header, "MESSAGE")
if listCmdOptions.ShowMessage {
header = append(header, "MESSAGE")
}

var flattenedPkgs []*list.PackageWithStatus
for _, pkgs := range packages {
Expand Down Expand Up @@ -225,7 +234,9 @@ func printPackageTable(packages []*list.PackagesWithStatus) {
row = append(row, pkg.ShortDescription)
}
row = append(row, statusString(*pkg))
row = append(row, messageString(*pkg))
if listCmdOptions.ShowMessage {
row = append(row, messageString(*pkg))
}
return row
})
if err != nil {
Expand Down

0 comments on commit c36ac48

Please sign in to comment.