Documentation
¶
Index ¶
- Variables
- func AskOne(p survey.Prompt, response any, opts ...survey.AskOpt) error
- func BarGraph(w io.Writer, data map[string]float64, caption string, width int, bytes bool) error
- func Base64IfNotPrintable(val []byte) string
- func ClearScreen()
- func CompactStrings(source []string) []string
- func ConfigDir() (string, error)
- func DecodeHeadersMsg(data []byte) (nats.Header, error)
- func EditFile(f string) error
- func FileExists(f string) bool
- func IsDirectory(path string) bool
- func IsFileAccessible(f string) (bool, error)
- func IsJsonObjectString(s string) bool
- func IsPrintable(s string) bool
- func IsTerminal() bool
- func JSONString(s string) string
- func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
- func NewProgress(opts *options.Options, tracker *progress.Tracker) (progress.Writer, *progress.Tracker, error)
- func ParentDir() (string, error)
- func ParseStringAsBytes(s string) (int64, error)
- func ParseStringsToHeader(hdrs []string, seq int) (nats.Header, error)
- func ParseStringsToMsgHeader(hdrs []string, seq int, msg *nats.Msg) error
- func PrintJSON(d any) error
- func ProgressWidth() int
- func PubReplyBodyTemplate(body string, request string, ctr int) ([]byte, error)
- func RandomPassword(length int) string
- func RandomString(shortest uint, longest uint) string
- func ReadKeyFile(filename string) ([]byte, error)
- func RemoveReservedMetadata(metadata map[string]string) map[string]string
- func RenderMetaApi(cols *columns.Writer, metadata map[string]string)
- func RequireAPILevel(m *jsm.Manager, lvl int, format string, a ...any) error
- func SaveConfig(cfg *Config) error
- func SelectPageSize(count int) int
- func ServerMinVersion(nc *nats.Conn, major, minor, patch int) bool
- func SliceGroups(input []string, size int, fn func(group []string))
- func SortMultiSort[V cmp.Ordered, S string | cmp.Ordered](i1 V, j1 V, i2 S, j2 S) bool
- func SplitCLISubjects(subjects []string) []string
- func SplitCommand(s string) (string, []string, error)
- func SplitString(s string) []string
- func StructWithoutOmitEmpty(s any) any
- func SurveyColors() []survey.AskOpt
- func ToJSON(d any) (string, error)
- func ValidStyles() []string
- func WipeSlice(buf []byte)
- func XdgShareHome() (string, error)
- type Config
- type Table
Constants ¶
This section is empty.
Variables ¶
var ProgressUnitsIBytes = progress.Units{ Notation: "", NotationPosition: progress.UnitsNotationPositionBefore, Formatter: func(v int64) string { return humanize.IBytes(uint64(v)) }, }
Functions ¶
func Base64IfNotPrintable ¶
Base64IfNotPrintable returns the bytes are all printable else a b64 encoded version
func ClearScreen ¶
func ClearScreen()
ClearScreen tries to ensure resetting original state of screen
func CompactStrings ¶
CompactStrings looks through a list of strings like hostnames and chops off the common parts like domains
func DecodeHeadersMsg ¶
DecodeHeadersMsg parses the data that includes headers into a header. Copied from nats.go
func EditFile ¶
EditFile edits the file at filepath f using the environment variable EDITOR command.
func FileExists ¶
FileExists checks if a file exist regardless of file kind
func IsDirectory ¶
IsDirectory returns true when path is a directory
func IsFileAccessible ¶
IsFileAccessible checks if f is a file and accessible, errors for non file arguments
func IsJsonObjectString ¶
IsJsonObjectString checks if a string is a JSON document starting and ending with {}
func IsPrintable ¶
IsPrintable checks if a string is made of only printable characters
func IsTerminal ¶
func IsTerminal() bool
IsTerminal checks if stdin and stdout are both normal terminals
func JSONString ¶
JSONString returns a quoted string to be used as a JSON object
func MapKeys ¶
func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
MapKeys extracts the keys from a map
func NewProgress ¶
func ParseStringAsBytes ¶
ParseStringAsBytes nats-server derived string parse, empty string and any negative is -1,others are parsed as 1024 based bytes
func ParseStringsToHeader ¶
ParseStringsToHeader creates a nats.Header from a list of strings like X:Y
func ParseStringsToMsgHeader ¶
ParseStringsToMsgHeader parsers strings of headers like X:Y into a supplied msg headers
func ProgressWidth ¶
func ProgressWidth() int
ProgressWidth calculates progress bar width for uiprogress:
if it cant figure out the width, assume 80 if the width is too small, set it to minWidth and just live with the overflow
this ensures a reasonable progress size, ideally we should switch over to a spinner for < minWidth rather than cause overflows, but thats for later.
func PubReplyBodyTemplate ¶
PubReplyBodyTemplate parses a message body using the usual template functions we support as standard
func RandomPassword ¶
RandomPassword generates a random string like RandomString() but includes some special characters
func RandomString ¶
RandomString generates a random string that includes only a-zA-Z0-9
func ReadKeyFile ¶
ReadKeyFile reads a nkey from a file
func RemoveReservedMetadata ¶
RemoveReservedMetadata returns a new version of metadata with reserved keys starting with _nats. removed
func RenderMetaApi ¶
RenderMetaApi draws the _nats.* metadata on streams and consumers
func RequireAPILevel ¶
RequireAPILevel asserts if the meta leader supports api level lvl
func SaveConfig ¶
func SelectPageSize ¶
SelectPageSize is the size of selection lists influence by screen size
func ServerMinVersion ¶
ServerMinVersion checks if the connected server meets certain version constraints
func SliceGroups ¶
SliceGroups calls fn repeatedly with a subset of input up to size big
func SortMultiSort ¶
func SplitCLISubjects ¶
SplitCLISubjects splits a subject list by comma, tab, space, unicode space etc
func SplitCommand ¶
SplitCommand Split the string into a command and its arguments.
func SplitString ¶
SplitString splits a string by unicode space or comma
func StructWithoutOmitEmpty ¶
StructWithoutOmitEmpty given a non pointer instance of a type with a lot of omitempty json tags will return a new instance without those
does not handle nested values
func SurveyColors ¶
SurveyColors determines colors for the survey package based on context and options set
func ValidStyles ¶
func ValidStyles() []string
ValidStyles are valid color styles this package supports
func XdgShareHome ¶
XdgShareHome is where to store data like nsc stored
Types ¶
type Config ¶
type Config struct {
SelectedOperator string `json:"select_operator"`
}
func LoadConfig ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) AddHeaders ¶
func (*Table) AddSeparator ¶
func (t *Table) AddSeparator()