human

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

Capitalize returns the given string with a first character in uppercase.

func Marshal

func Marshal(data interface{}, opt *MarshalOpt) (string, error)

func RegisterMarshalerFunc

func RegisterMarshalerFunc(i interface{}, f MarshalerFunc)

TODO: implement the same logic as args.RegisterMarshalFunc(), where i must be a pointer RegisterMarshalerFunc bind the given type of i with the given MarshalerFunc

Types

type EnumMarshalSpec

type EnumMarshalSpec struct {
	// Attribute (mainly colors) to use.
	Attribute color.Attribute

	// Value is the value that will be printed for the given value.
	Value string
}

EnumMarshalSpec contains specs used by EnumMarshalFunc.

type EnumMarshalSpecs

type EnumMarshalSpecs map[interface{}]*EnumMarshalSpec

type MarshalFieldOpt

type MarshalFieldOpt struct {
	FieldName string
	Label     string
}

type MarshalOpt

type MarshalOpt struct {
	Title    string
	Fields   []*MarshalFieldOpt
	Sections []*MarshalSection

	// Is set to true if we are marshaling a table cell
	TableCell bool

	// DisableShrinking will disable columns shrinking based on terminal size
	DisableShrinking bool
}

MarshalOpt is hydrated by core.View

type MarshalSection

type MarshalSection struct {
	FieldName   string
	Title       string
	HideIfEmpty bool
}

MarshalSection describes a section to build from a given struct. When marshalling, this section is shown under the main struct section.

type Marshaler

type Marshaler interface {
	MarshalHuman() (string, error)
}

Marshaler allow custom display for some type when printed using HumanPrinter

type MarshalerFunc

type MarshalerFunc func(interface{}, *MarshalOpt) (string, error)

func EnumMarshalFunc

func EnumMarshalFunc(specs EnumMarshalSpecs) MarshalerFunc

EnumMarshalFunc returns a marshal func to marshal an enum.

type UnknownFieldError

type UnknownFieldError struct {
	FieldName   string
	ValidFields []string
}

func (*UnknownFieldError) Error

func (u *UnknownFieldError) Error() string

Jump to

Keyboard shortcuts

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