cmdutil

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 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

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

type Codec interface {
	Serializer
	Deserializer
}

func CodecFor

func CodecFor(s string) (Codec, error)

func NewJSONCodec

func NewJSONCodec() Codec

func NewYamlCodec

func NewYamlCodec() Codec

type Color

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

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

Dashboard holds all services + rendering logic

func NewDashboard

func NewDashboard(names []string) *Dashboard

NewDashboard creates the dashboard with one ServiceState per name.

func (*Dashboard) Done

func (d *Dashboard) Done(idx int)

func (*Dashboard) DoneMsg

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

func (*Dashboard) Fail

func (d *Dashboard) Fail(idx int)

func (*Dashboard) FailAfter

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

func (*Dashboard) FailAfterMsg

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

func (*Dashboard) FailMsg

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

func (*Dashboard) IsDone

func (d *Dashboard) IsDone() bool

func (*Dashboard) Loop

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

Loop runs the renderer until ctx is done.

func (*Dashboard) Update

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

Update lets workers mutate a single service under lock.

func (*Dashboard) Wait

func (d *Dashboard) Wait()

Wait blocks until Loop finishes.

func (*Dashboard) WaitAnd

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

type Deserializer

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

func DeserializerFor

func DeserializerFor(s string) (Deserializer, error)

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{}

func (*JSONSerializer) Serialize

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

type NewSpinnerOpt

type NewSpinnerOpt func(*Spinner)

func WithPrefix

func WithPrefix(str string) NewSpinnerOpt

func WithWriter

func WithWriter(w io.Writer) NewSpinnerOpt

type OutputFormat

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

type Serializer

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

func SerializerFor

func SerializerFor(s string) (Serializer, error)

type ServiceState

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

func (s *Spinner) NewLine()

func (*Spinner) Start

func (s *Spinner) Start()

func (*Spinner) Stop

func (s *Spinner) Stop()

func (*Spinner) StopMsg

func (s *Spinner) StopMsg(finalText string)

func (*Spinner) Update

func (s *Spinner) Update(text string)

type StopFunc

type StopFunc func()

type SyncWriter

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

func (*SyncWriter) Write

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

type TableSerializer

type TableSerializer struct{}

func (*TableSerializer) Serialize

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

type WatchFunc

type WatchFunc func(StopFunc) error

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{}

func (*YamlSerializer) Serialize

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