Documentation ¶
Index ¶
- Constants
- Variables
- func PrintJobExecution(ctx context.Context, jobID string, cmd *cobra.Command, ...) error
- func PrintJobExecutionLegacy(ctx context.Context, j *model.Job, cmd *cobra.Command, ...) error
- func WaitForJobAndPrintResultsToUser(ctx context.Context, cmd *cobra.Command, j *model.Job, quiet bool) error
- type LineMessage
- type SpinActionType
- type Spinner
- type SpinnerStopReason
Constants ¶
const ( TickerUpdateFrequency = 50 * time.Millisecond SpinnerFormatDurationDefault = 30 * time.Millisecond TextLineupSpacing = 10 )
const ( SpacerText = " ... " ReverseText = " ... " )
const ( StatusNone = " " StatusDone = "done ✅" StatusWait = "wait ⏳" StatusErr = "err ❌" )
const ( WidthDots = 16 WidthStatus = 6 // Don't left pad the timer column because we want it to be left aligned. WidthTimer = 0 )
const PrintoutCanceledButRunningNormally string = "printout canceled but running normally"
Variables ¶
var SpinnerEmoji = [...]string{"🐟", "🐠", "🐡"}
Functions ¶
func PrintJobExecution ¶
func PrintJobExecution( ctx context.Context, jobID string, cmd *cobra.Command, runtimeSettings *cliflags.RunTimeSettings, client *clientv2.Client, ) error
PrintJobExecution displays information about the execution of a job
func PrintJobExecutionLegacy ¶ added in v1.1.0
func PrintJobExecutionLegacy( ctx context.Context, j *model.Job, cmd *cobra.Command, downloadSettings *cliflags.DownloaderSettings, runtimeSettings *cliflags.RunTimeSettingsWithDownload, client *client.APIClient, ) error
PrintJobExecutionLegacy displays information about the execution of a job TODO gocyclo rates this as a 24, which is very high, we should refactor someday.
func WaitForJobAndPrintResultsToUser ¶
func WaitForJobAndPrintResultsToUser(ctx context.Context, cmd *cobra.Command, j *model.Job, quiet bool) error
WaitForJobAndPrintResultsToUser uses events to decide what to output to the terminal using a spinner to show long-running tasks. When the job is complete (or the user triggers SIGINT) then the function will complete and stop outputting to the terminal.
Types ¶
type LineMessage ¶
type LineMessage struct { Message string Detail string TimerString string Waiting bool Failure bool ColumnWidths []uint8 }
func NewLineMessage ¶
func NewLineMessage(msg string, maxWidth int) LineMessage
func (*LineMessage) BlankSpinner ¶
func (f *LineMessage) BlankSpinner(col int) string
func (*LineMessage) PrintOnCancel ¶
func (f *LineMessage) PrintOnCancel() string
func (*LineMessage) PrintOnDone ¶
func (f *LineMessage) PrintOnDone() string
func (*LineMessage) PrintOnFail ¶
func (f *LineMessage) PrintOnFail() string
func (*LineMessage) SpinnerMessage ¶
func (f *LineMessage) SpinnerMessage() string
func (*LineMessage) SpinnerPrefix ¶
func (f *LineMessage) SpinnerPrefix() string
type SpinActionType ¶
type SpinActionType int
const ( SpinActionStart SpinActionType = iota SpinActionStop )
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶
func NewSpinner(ctx context.Context, w io.Writer, maxWidth int, handleSigint bool) (*Spinner, error)
NewSpinner creates a new `Spinner` using the provided io.Writer and expecting a message of no more than `maxWidth` characters. The `maxWidth` is required to ensure that following steps in the lifetime of the spinner line up.
func (*Spinner) Done ¶
func (s *Spinner) Done(reason SpinnerStopReason)
Done stops the spinner, igoring any errors as there is no further use for the spinner.
type SpinnerStopReason ¶
type SpinnerStopReason int
const ( StopSuccess SpinnerStopReason = iota StopFailed StopCancel )