github.com/cloudfoundry/cli@v7.1.0+incompatible/util/ui/ui_for_app.go (about)

     1  package ui
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/fatih/color"
     7  )
     8  
     9  func (ui *UI) DisplayInstancesTableForApp(table [][]string) {
    10  	redColor := color.New(color.FgRed, color.Bold)
    11  	trDown, trCrashed := ui.TranslateText("down"), ui.TranslateText("crashed")
    12  
    13  	for i, row := range table {
    14  		if row[1] == trDown || row[1] == trCrashed {
    15  			table[i][1] = ui.modifyColor(row[1], redColor)
    16  		}
    17  	}
    18  	ui.DisplayTableWithHeader("", table, DefaultTableSpacePadding)
    19  }
    20  
    21  func (ui *UI) DisplayKeyValueTableForApp(table [][]string) {
    22  	runningInstances := strings.Split(table[2][1], "/")[0]
    23  	state := table[1][1]
    24  
    25  	if runningInstances == "0" && state != ui.TranslateText("stopped") {
    26  		redColor := color.New(color.FgRed, color.Bold)
    27  		table[1][1] = ui.modifyColor(table[1][1], redColor)
    28  		table[2][1] = ui.modifyColor(table[2][1], redColor)
    29  	}
    30  	ui.DisplayKeyValueTable("", table, 3)
    31  }