github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/control/controldisplay/spacer.go (about) 1 package controldisplay 2 3 import ( 4 "fmt" 5 "log" 6 "strings" 7 ) 8 9 type SpacerRenderer struct { 10 width int 11 } 12 13 func NewSpacerRenderer(width int) *SpacerRenderer { 14 return &SpacerRenderer{width} 15 } 16 17 // Render returns a divider string of format: "....... " 18 // NOTE: adds a trailing space 19 func (r SpacerRenderer) Render() string { 20 if r.width <= 0 { 21 // this should never happen, since the minimum width is set by the formatter 22 log.Printf("[WARN] spacer renderer has width of %d\n", r.width) 23 return "" 24 } 25 // we always have a trailing space 26 if r.width == 1 { 27 return " " 28 } 29 30 // allow for trailing space 31 numberOfDots := r.width - 1 32 return fmt.Sprintf("%s ", ControlColors.Spacer(strings.Repeat(".", numberOfDots))) 33 }