cmdutil

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cmdutil provides helper utilities and interfaces for working with command line tools

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

func FormatPhase

func FormatPhase(phase string) string

func ParseVersion added in v0.0.9

func ParseVersion(in string) (string, error)

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.

func Watch

func Watch(ctx context.Context, id string, wf WatchFunc) error

Types

type Codec added in v0.0.7

type Codec interface {
	Serializer
	Deserializer
}

func CodecFor added in v0.0.7

func CodecFor(s string) (Codec, error)

func NewJSONCodec added in v0.0.7

func NewJSONCodec() Codec

func NewYamlCodec added in v0.0.7

func NewYamlCodec() Codec

type Color added in v0.0.7

type Color string
const (
	ColorReset  Color = "\x1b[0m"
	ColorRed    Color = "\x1b[31m"
	ColorGreen  Color = "\x1b[32m"
	ColorYellow Color = "\x1b[33m"
	ColorCyan   Color = "\x1b[36m"
)

type Dashboard added in v0.0.7

type Dashboard struct {
	// contains filtered or unexported fields
}

Dashboard holds all services + rendering logic

func NewDashboard added in v0.0.7

func NewDashboard(names []string) *Dashboard

NewDashboard creates the dashboard with one ServiceState per name.

func (*Dashboard) Done added in v0.0.7

func (d *Dashboard) Done(idx int)

func (*Dashboard) DoneMsg added in v0.0.7

func (d *Dashboard) DoneMsg(idx int, msg string)

func (*Dashboard) Fail added in v0.0.7

func (d *Dashboard) Fail(idx int)

func (*Dashboard) FailAfter added in v0.0.7

func (d *Dashboard) FailAfter(idx int, after time.Duration)

func (*Dashboard) FailAfterMsg added in v0.0.7

func (d *Dashboard) FailAfterMsg(idx int, after time.Duration, msg string)

func (*Dashboard) FailMsg added in v0.0.7

func (d *Dashboard) FailMsg(idx int, msg string)

func (*Dashboard) IsDone added in v0.0.7

func (d *Dashboard) IsDone() bool

func (*Dashboard) Loop added in v0.0.7

func (d *Dashboard) Loop(ctx context.Context)

Loop runs the renderer until ctx is done.

func (*Dashboard) Update added in v0.0.7

func (d *Dashboard) Update(idx int, fn func(s *ServiceState))

Update lets workers mutate a single service under lock.

func (*Dashboard) Wait added in v0.0.7

func (d *Dashboard) Wait()

Wait blocks until Loop finishes.

func (*Dashboard) WaitAnd added in v0.0.7

func (d *Dashboard) WaitAnd(fn func())

type Deserializer added in v0.0.7

type Deserializer interface {
	Deserialize(b []byte, m proto.Message) error
}

func DeserializerFor added in v0.0.7

func DeserializerFor(s string) (Deserializer, error)

type JSONCodec added in v0.0.7

type JSONCodec struct {
	*JSONSerializer
	*JSONDeserializer
}

type JSONDeserializer added in v0.0.7

type JSONDeserializer struct{}

func (*JSONDeserializer) Deserialize added in v0.0.7

func (d *JSONDeserializer) Deserialize(b []byte, m proto.Message) error

type JSONSerializer added in v0.0.7

type JSONSerializer struct{}

func (*JSONSerializer) Serialize added in v0.0.7

func (s *JSONSerializer) Serialize(m proto.Message) ([]byte, error)

type NewSpinnerOpt

type NewSpinnerOpt func(*Spinner)

func WithPrefix

func WithPrefix(str string) NewSpinnerOpt

func WithWriter added in v0.0.7

func WithWriter(w io.Writer) NewSpinnerOpt

type OutputFormat added in v0.0.7

type OutputFormat string
var (
	OutputFormatJSON  OutputFormat = "json"
	OutputFormatYAML  OutputFormat = "yaml"
	OutputFormatTable OutputFormat = "table"
)

type Serializer added in v0.0.7

type Serializer interface {
	Serialize(m proto.Message) ([]byte, error)
}

func SerializerFor added in v0.0.7

func SerializerFor(s string) (Serializer, error)

type ServiceState added in v0.0.7

type ServiceState struct {
	Name   string
	Text   string
	Color  Color
	Done   bool
	Failed bool
	// contains filtered or unexported fields
}

ServiceState represents One line in the dashboard

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

func NewSpinner

func NewSpinner(opts ...NewSpinnerOpt) *Spinner

func (*Spinner) NewLine added in v0.0.7

func (s *Spinner) NewLine()

func (*Spinner) Start

func (s *Spinner) Start()

func (*Spinner) Stop

func (s *Spinner) Stop()

func (*Spinner) StopMsg added in v0.0.7

func (s *Spinner) StopMsg(finalText string)

func (*Spinner) Update added in v0.0.7

func (s *Spinner) Update(text string)

type StopFunc

type StopFunc func()

type SyncWriter added in v0.0.7

type SyncWriter struct {
	// contains filtered or unexported fields
}

func (*SyncWriter) Write added in v0.0.7

func (sw *SyncWriter) Write(p []byte) (int, error)

type TableSerializer added in v0.0.7

type TableSerializer struct{}

func (*TableSerializer) Serialize added in v0.0.7

func (s *TableSerializer) Serialize(m proto.Message) ([]byte, error)

type WatchFunc

type WatchFunc func(StopFunc) error

type YamlCodec added in v0.0.7

type YamlCodec struct {
	*YamlSerializer
	*YamlDeserializer
}

type YamlDeserializer added in v0.0.7

type YamlDeserializer struct{}

func (*YamlDeserializer) Deserialize added in v0.0.7

func (d *YamlDeserializer) Deserialize(b []byte, m proto.Message) error

type YamlSerializer added in v0.0.7

type YamlSerializer struct{}

func (*YamlSerializer) Serialize added in v0.0.7

func (s *YamlSerializer) Serialize(m proto.Message) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL