ux

package
v1.102.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package ux provides user experience utilities including logging and progress display.

Index

Constants

This section is empty.

Variables

View Source
var (
	AlignLeft   = tw.AlignLeft
	AlignCenter = tw.AlignCenter
	AlignRight  = tw.AlignRight
)

Alignment constants for backward compatibility

Functions

func ConvertToStringWithThousandSeparator

func ConvertToStringWithThousandSeparator(input uint64) string

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

func FormatDuration(d time.Duration) string

FormatDuration returns a user friendly string for a duration

func NewUserLog

func NewUserLog(log luxlog.Logger, userwriter io.Writer)

func PrintCompactChainEndpoints added in v1.13.7

func PrintCompactChainEndpoints(portBase int)

PrintCompactChainEndpoints prints chain endpoints in a compact format.

Labels and addresses are measured rather than hand-padded, so the box stays square whatever the route segment is. It used to be padded by hand against a segment two characters long, and would have come out ragged the moment that changed.

func PrintTableEndpoints

func PrintTableEndpoints(clusterInfo *rpcpb.ClusterInfo)

PrintTableEndpoints prints the endpoints coming from the healthy call

func PrintValidatorKeys added in v1.13.7

func PrintValidatorKeys(validators []ValidatorKeyInfo, networkHRP string)

PrintValidatorKeys prints validator key information in a formatted table

func PrintValidatorKeysCompact added in v1.13.7

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 SpinComplete(s *ysmrr.Spinner)

func SpinFailWithError

func SpinFailWithError(s *ysmrr.Spinner, txt string, err error)

func TimedProgressBar

func TimedProgressBar(
	duration time.Duration,
	title string,
	extraSteps int,
) (*progressbar.ProgressBar, error)

Types

type NativeChainInfo added in v1.13.7

type NativeChainInfo struct {
	Letter string // P, C, X, Q, A, B, T, Z, G, K, D
	Name   string // Platform, EVM, Exchange, etc.
	Type   string // RPC or WS
	Under  string // what the chain answers under: nothing at its root, "/rpc", "/ws"
}

NativeChainInfo holds info for pretty-printing a native chain

func GetNativeChains added in v1.13.7

func GetNativeChains() []NativeChainInfo

GetNativeChains returns all native chain definitions for RPC display. P and X answer at the chain's root; the EVM chains answer under /rpc.

func (NativeChainInfo) Address added in v1.102.5

func (c NativeChainInfo) Address(uri string) string

Address is where this chain answers on the node at uri.

type StepTracker added in v1.13.7

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

StepTracker tracks progress of multi-step operations with elapsed time

func NewStepTracker added in v1.13.7

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.13.7

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.13.7

func (st *StepTracker) Complete(suffix string)

Complete marks the step as done with success

func (*StepTracker) CompleteSuccess added in v1.13.7

func (st *StepTracker) CompleteSuccess()

CompleteSuccess is shorthand for Complete with "Success" suffix

func (*StepTracker) Elapsed added in v1.13.7

func (st *StepTracker) Elapsed() time.Duration

Elapsed returns the elapsed time for the current step

func (*StepTracker) Failed added in v1.13.7

func (st *StepTracker) Failed(reason string)

Failed marks the step as failed with an error

func (*StepTracker) Start added in v1.13.7

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) Error

func (ul *UserLog) Error(msg string, args ...interface{})

Error logs an error message

func (*UserLog) GreenCheckmarkToUser

func (ul *UserLog) GreenCheckmarkToUser(msg string, args ...interface{})

GreenCheckmarkToUser prints a green checkmark success message to the user

func (*UserLog) Info

func (ul *UserLog) Info(msg string, args ...interface{})

Info logs an info message

func (*UserLog) PrintError added in v1.13.7

func (ul *UserLog) PrintError(msg string, args ...interface{})

PrintError prints a visible error message with ERROR prefix to the user

func (*UserLog) PrintLineSeparator

func (ul *UserLog) PrintLineSeparator(msg ...string)

PrintLineSeparator prints a line separator

func (*UserLog) PrintToUser

func (ul *UserLog) PrintToUser(msg string, args ...interface{})

PrintToUser prints msg directly to stdout (command output) Does NOT log to avoid duplication - logs should go to stderr separately

func (*UserLog) RedXToUser

func (ul *UserLog) RedXToUser(msg string, args ...interface{})

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()

type ValidatorKeyInfo added in v1.13.7

type ValidatorKeyInfo struct {
	Index      int
	NodeID     string
	PChainAddr string
	XChainAddr string
	CChainAddr string // Ethereum-style 0x address
	BLSPubKey  string // Hex-encoded BLS public key
}

ValidatorKeyInfo holds derived key info for a validator

Jump to

Keyboard shortcuts

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