human

package
v0.0.0-...-f46f4bb Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

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
}

MarshalOpt is hydrated by core.View

type MarshalSection

type MarshalSection struct {
	FieldName string
	Title     string
}

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