Files
nomad/vendor/github.com/mitchellh/go-glint/text.go
Isabel Suchanek 0edda116ad cli: add monitor flag to deployment status
Adding '-verbose' will print out the allocation information for the
deployment. This also changes the job run command so that it now blocks
until deployment is complete and adds timestamps to the output so that
it's more in line with the output of node drain.

This uses glint to print in place in running in a tty. Because glint
doesn't yet support cmd/powershell, Windows workflows use a different
library to print in place, which results in slightly different
formatting: 1) different margins, and 2) no spinner indicating
deployment in progress.
2021-06-09 16:18:45 -07:00

38 lines
798 B
Go

package glint
import (
"context"
)
// TextComponent is a Component that renders text.
type TextComponent struct {
terminalComponent
f func(rows, cols uint) string
}
// Text creates a TextComponent for static text. The text here will be word
// wrapped automatically based on the width of the terminal.
func Text(v string) *TextComponent {
return TextFunc(func(rows, cols uint) string { return v })
}
// TextFunc creates a TextComponent for text that is dependent on the
// size of the draw area.
func TextFunc(f func(rows, cols uint) string) *TextComponent {
return &TextComponent{
f: f,
}
}
func (el *TextComponent) Body(context.Context) Component {
return nil
}
func (el *TextComponent) Render(rows, cols uint) string {
if el.f == nil {
return ""
}
return el.f(rows, cols)
}