Documentation
¶
Overview ¶
Package cmdutil provides helper utilities and interfaces for working with command line tools
Index ¶
- Variables
- func FormatDuration(d time.Duration) string
- func FormatPhase(phase string) string
- func ParseVersion(in string) (string, error)
- func Watch(ctx context.Context, id string, wf WatchFunc) error
- type Codec
- type Color
- type Dashboard
- func (d *Dashboard) Done(idx int)
- func (d *Dashboard) DoneMsg(idx int, msg string)
- func (d *Dashboard) Fail(idx int)
- func (d *Dashboard) FailAfter(idx int, after time.Duration)
- func (d *Dashboard) FailAfterMsg(idx int, after time.Duration, msg string)
- func (d *Dashboard) FailMsg(idx int, msg string)
- func (d *Dashboard) IsDone() bool
- func (d *Dashboard) Loop(ctx context.Context)
- func (d *Dashboard) SetDetails(idx int, lines []Detail)
- func (d *Dashboard) Update(idx int, fn func(s *ServiceState))
- func (d *Dashboard) UpdateDetails(idx int, key, value string)
- func (d *Dashboard) UpdateText(idx int, text string)
- func (d *Dashboard) Wait()
- func (d *Dashboard) WaitAnd(fn func())
- type Deserializer
- type Detail
- type JSONCodec
- type JSONDeserializer
- type JSONSerializer
- type Option
- type OutputFormat
- type Serializer
- type ServiceState
- type StopFunc
- type SyncWriter
- type TableSerializer
- type WatchFunc
- type YamlCodec
- type YamlDeserializer
- type YamlSerializer
Constants ¶
This section is empty.
Variables ¶
var DefaultTabWriter = tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0)
Functions ¶
func FormatDuration ¶
func FormatPhase ¶
func ParseVersion ¶
ParseVersion parses the provided string and ensures that it is a valid. Allowed values are either semver (prefixed with v), "latest" and "head". Case is ignored. If the version is valid, this function will resolv the version to a GitHub release name to ensure that the release exists.
Types ¶
type Codec ¶
type Codec interface {
Serializer
Deserializer
}
func NewJSONCodec ¶
func NewJSONCodec() Codec
func NewYamlCodec ¶
func NewYamlCodec() Codec
type Dashboard ¶
type Dashboard struct {
// contains filtered or unexported fields
}
Dashboard holds all services + rendering logic
func NewDashboard ¶
NewDashboard creates the dashboard with one ServiceState per name.
func (*Dashboard) FailAfterMsg ¶
FailAfterMsg sets the provided message marks the service as faild when x amount of time as elapsed
func (*Dashboard) SetDetails ¶ added in v0.0.11
SetDetails assigns a new slice, overwriting any other Detail sets previously used. If you want to update an existing line then use UpdateDetail()
func (*Dashboard) Update ¶
func (d *Dashboard) Update(idx int, fn func(s *ServiceState))
Update lets workers mutate a single service under lock.
func (*Dashboard) UpdateDetails ¶ added in v0.0.11
UpdateDetails inserts a new line. If a line with same key exists then that line is updated. So two lines with the same key cannot exist in the slice.
func (*Dashboard) UpdateText ¶ added in v0.0.11
UpdateText lets workers mutate a single service under lock.
type Deserializer ¶
func DeserializerFor ¶
func DeserializerFor(s string) (Deserializer, error)
type Detail ¶ added in v0.0.11
Detail represents a line in the details view of a ServiceState. It's pretty much just a key-value pair
type JSONCodec ¶
type JSONCodec struct {
*JSONSerializer
*JSONDeserializer
}
type JSONDeserializer ¶
type JSONDeserializer struct{}
func (*JSONDeserializer) Deserialize ¶
func (d *JSONDeserializer) Deserialize(b []byte, m proto.Message) error
type JSONSerializer ¶
type JSONSerializer struct{}
type Option ¶ added in v0.0.11
type Option func(*Dashboard)
func WithFlushFunc ¶ added in v0.0.11
func WithFlushFunc(f func()) Option
WithFlushFunc adds a handler to the dashboard that is executed on each render loop. This is useful when for writers that require flushing. Such as the build-in tabwriter pkg writer.
func WithWriter ¶
WithWriter assigns a io.Writer that the Dashboard will render to. The default writer is os.Stdout. If the writer literal types can be cast to a tabwriter.Writer its Flush() methods will be assigned as the loopFunc. see WithLoopFunc for more info. Basically it is set here so the user doesn't have to bother.
type OutputFormat ¶
type OutputFormat string
var ( OutputFormatJSON OutputFormat = "json" OutputFormatYAML OutputFormat = "yaml" OutputFormatTable OutputFormat = "table" )
type Serializer ¶
func SerializerFor ¶
func SerializerFor(s string) (Serializer, error)
type ServiceState ¶
type ServiceState struct {
Name string
Text string
Color Color
Done bool
Failed bool
Details []Detail
// contains filtered or unexported fields
}
ServiceState represents One line in the dashboard
type SyncWriter ¶
type SyncWriter struct {
// contains filtered or unexported fields
}
type TableSerializer ¶
type TableSerializer struct{}
type YamlCodec ¶
type YamlCodec struct {
*YamlSerializer
*YamlDeserializer
}
type YamlDeserializer ¶
type YamlDeserializer struct{}
func (*YamlDeserializer) Deserialize ¶
func (d *YamlDeserializer) Deserialize(b []byte, m proto.Message) error
type YamlSerializer ¶
type YamlSerializer struct{}