Documentation
¶
Overview ¶
Package ux provides user experience utilities including logging and progress display.
Index ¶
- Variables
- func ConvertToStringWithThousandSeparator(input uint64) string
- func DefaultTable(title string, headers []string) *tablewriter.Table
- func ExtraStepExecuted(bar *progressbar.ProgressBar) error
- func FormatDuration(d time.Duration) string
- func NewUserLog(log luxlog.Logger, userwriter io.Writer)
- func PrintCompactChainEndpoints(portBase int)
- func PrintNativeChainEndpoints(baseURL string, portBase int, includeUtility bool)
- func PrintTableEndpoints(clusterInfo *rpcpb.ClusterInfo)
- func PrintValidatorKeys(validators []ValidatorKeyInfo, networkHRP string)
- func PrintValidatorKeysCompact(validators []ValidatorKeyInfo)
- func PrintWait(cancel chan struct{})
- func SpinComplete(s *ysmrr.Spinner)
- func SpinFailWithError(s *ysmrr.Spinner, txt string, err error)
- func TimedProgressBar(duration time.Duration, title string, extraSteps int) (*progressbar.ProgressBar, error)
- type NativeChainInfo
- type StepTracker
- type TableCompatWrapper
- type UserLog
- func (ul *UserLog) Error(msg string, args ...interface{})
- func (ul *UserLog) GreenCheckmarkToUser(msg string, args ...interface{})
- func (ul *UserLog) Info(msg string, args ...interface{})
- func (ul *UserLog) PrintError(msg string, args ...interface{})
- func (ul *UserLog) PrintLineSeparator(msg ...string)
- func (ul *UserLog) PrintToUser(msg string, args ...interface{})
- func (ul *UserLog) RedXToUser(msg string, args ...interface{})
- type UserSpinner
- type ValidatorKeyInfo
Constants ¶
This section is empty.
Variables ¶
var ( AlignLeft = tw.AlignLeft AlignCenter = tw.AlignCenter AlignRight = tw.AlignRight )
Alignment constants for backward compatibility
Functions ¶
func DefaultTable ¶
func DefaultTable(title string, headers []string) *tablewriter.Table
DefaultTable creates a default table with the given title and headers
func ExtraStepExecuted ¶
func ExtraStepExecuted(bar *progressbar.ProgressBar) error
func FormatDuration ¶
FormatDuration returns a user friendly string for a duration
func PrintCompactChainEndpoints ¶ added in v1.22.8
func PrintCompactChainEndpoints(portBase int)
PrintCompactChainEndpoints prints chain endpoints in a compact format
func PrintNativeChainEndpoints ¶ added in v1.22.8
PrintNativeChainEndpoints prints all native chain RPC endpoints in a formatted table
func PrintTableEndpoints ¶
func PrintTableEndpoints(clusterInfo *rpcpb.ClusterInfo)
PrintTableEndpoints prints the endpoints coming from the healthy call
func PrintValidatorKeys ¶ added in v1.22.8
func PrintValidatorKeys(validators []ValidatorKeyInfo, networkHRP string)
PrintValidatorKeys prints validator key information in a formatted table
func PrintValidatorKeysCompact ¶ added in v1.22.8
func PrintValidatorKeysCompact(validators []ValidatorKeyInfo)
PrintValidatorKeysCompact prints validator keys in a compact single-line format
func PrintWait ¶
func PrintWait(cancel chan struct{})
PrintWait does some dot printing to entertain the user
func SpinComplete ¶
func TimedProgressBar ¶
func TimedProgressBar( duration time.Duration, title string, extraSteps int, ) (*progressbar.ProgressBar, error)
Types ¶
type NativeChainInfo ¶ added in v1.22.8
type NativeChainInfo struct {
Letter string // P, C, X, Q, A, B, T, Z, G, K, D
Name string // Platform, Contract, Exchange, etc.
Type string // RPC endpoint type
Path string // URL path suffix
}
NativeChainInfo holds info for pretty-printing a native chain
func GetNativeChains ¶ added in v1.22.8
func GetNativeChains() []NativeChainInfo
GetNativeChains returns all native chain definitions for RPC display
type StepTracker ¶ added in v1.22.6
type StepTracker struct {
// contains filtered or unexported fields
}
StepTracker tracks progress of multi-step operations with elapsed time
func NewStepTracker ¶ added in v1.22.6
func NewStepTracker(ul *UserLog, warnAfter time.Duration) *StepTracker
NewStepTracker creates a tracker that warns if a step takes longer than warnAfter
func (*StepTracker) CheckWarn ¶ added in v1.22.6
func (st *StepTracker) CheckWarn() bool
CheckWarn prints a warning if the step has taken longer than the threshold Returns true if warning was printed
func (*StepTracker) Complete ¶ added in v1.22.6
func (st *StepTracker) Complete(suffix string)
Complete marks the step as done with success
func (*StepTracker) CompleteSuccess ¶ added in v1.22.6
func (st *StepTracker) CompleteSuccess()
CompleteSuccess is shorthand for Complete with "Success" suffix
func (*StepTracker) Elapsed ¶ added in v1.22.6
func (st *StepTracker) Elapsed() time.Duration
Elapsed returns the elapsed time for the current step
func (*StepTracker) Failed ¶ added in v1.22.6
func (st *StepTracker) Failed(reason string)
Failed marks the step as failed with an error
func (*StepTracker) Start ¶ added in v1.22.6
func (st *StepTracker) Start(stepName string)
Start begins tracking a new step
type TableCompatWrapper ¶ added in v1.9.5
type TableCompatWrapper struct {
*tablewriter.Table
// contains filtered or unexported fields
}
TableCompatWrapper provides backward compatibility for tablewriter v0.0.5 API on top of tablewriter v1.0.9+
func CreateCompatTable ¶ added in v1.9.5
func CreateCompatTable() *TableCompatWrapper
CreateCompatTable creates a table with v0.0.5-like API
func NewCompatTable ¶ added in v1.9.5
func NewCompatTable() *TableCompatWrapper
NewCompatTable creates a new table with v0.0.5-like API
func (*TableCompatWrapper) AppendCompat ¶ added in v1.9.5
func (t *TableCompatWrapper) AppendCompat(row []string)
AppendCompat adds a row using string slice (old API)
func (*TableCompatWrapper) SetAlignment ¶ added in v1.9.5
func (t *TableCompatWrapper) SetAlignment(align tw.Align)
SetAlignment sets the alignment for rows
func (*TableCompatWrapper) SetAutoMergeCells ¶ added in v1.9.5
func (*TableCompatWrapper) SetAutoMergeCells(_ bool)
SetAutoMergeCells is a no-op in v1.0.9 (merge mode controlled via config)
func (*TableCompatWrapper) SetHeader ¶ added in v1.9.5
func (t *TableCompatWrapper) SetHeader(headers []string)
SetHeader sets the headers using the old API
func (*TableCompatWrapper) SetRowLine ¶ added in v1.9.5
func (*TableCompatWrapper) SetRowLine(_ bool)
SetRowLine is a no-op in v1.0.9 (row lines controlled via renderer settings)
type UserLog ¶
type UserLog struct {
// contains filtered or unexported fields
}
var Logger *UserLog
func (*UserLog) GreenCheckmarkToUser ¶
GreenCheckmarkToUser prints a green checkmark success message to the user
func (*UserLog) PrintError ¶ added in v1.21.40
PrintError prints a visible error message with ERROR prefix to the user
func (*UserLog) PrintLineSeparator ¶
PrintLineSeparator prints a line separator
func (*UserLog) PrintToUser ¶
PrintToUser prints msg directly on the screen, but also to log file
func (*UserLog) RedXToUser ¶
RedXToUser prints a red X error message to the user
type UserSpinner ¶
type UserSpinner struct {
// contains filtered or unexported fields
}
func NewUserSpinner ¶
func NewUserSpinner() *UserSpinner
func (*UserSpinner) SpinToUser ¶
func (us *UserSpinner) SpinToUser(msg string, args ...interface{}) *ysmrr.Spinner
func (*UserSpinner) Stop ¶
func (us *UserSpinner) Stop()