show

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: MIT Imports: 3 Imported by: 0

README

Format message

contains section, panel, padding, helpPanel, table, tree, title, list, multiList

  • title

  • table

  • panel

  • section

  • padding

  • list

  • multi list

  • alert(block)

  • markdown

  • json

Documentation

Index

Constants

View Source
const (
	// OK success exit code
	OK = 0
	// ERR error exit code
	ERR = 2
)

Variables

This section is empty.

Functions

func AList added in v1.1.2

func AList()

AList show a list data

func Error

func Error(format string, v ...interface{}) int

Error tips message print

func JSON

func JSON(v interface{}, settings ...string) int

JSON print pretty JSON data

func MList added in v1.1.2

func MList()

AList show multi list data

func Success added in v1.1.2

func Success(format string, v ...interface{}) int

Success tips message print

Types

type Base added in v1.1.2

type Base struct {
}

Base formatter

func (*Base) Format added in v1.1.2

func (f *Base) Format() string

Format given data to string

func (*Base) Print added in v1.1.2

func (f *Base) Print()

Print formatted message

func (*Base) Println added in v1.1.2

func (f *Base) Println()

Println formatted message and print newline

func (*Base) String added in v1.1.2

func (f *Base) String() string

String returns formatted string

type FormatterFace added in v1.1.2

type FormatterFace interface {
	Format() string
}

FormatterFace

type List

type List struct {
	Base // use for internal
	// Title list title name
	Title string
	// Items list items.
	// allow:
	// 	struct, []int, []string, []interface{}, map[string]string, map[string]interface{}
	Items interface{}
	// NewLine print "\n" at last
	NewLine bool
	// contains filtered or unexported fields
}

List definition

String len:

len("你好"), len("hello"), len("hello你好") -> 6 5 11

func NewList

func NewList(title string, items interface{}) *List

NewList instance

func (*List) Format

func (l *List) Format() string

func (*List) Print

func (l *List) Print()

type Lists

type Lists struct {
	Base  // use for internal
	Title string
	Rows  []List
}

Lists definition

func NewLists

func NewLists(title string, lists []List) *Lists

NewLists

func (*Lists) Format

func (ls *Lists) Format() string

func (*Lists) Print

func (ls *Lists) Print()

type ShownFace added in v1.1.2

type ShownFace interface {
	// data to string
	String() string
	// print current message
	Print()
	// print current message
	Println()
}

ShownFace shown

type Table

type Table struct {
	Base // use for internal
	// Title for the table
	Title string
	// Cols the table head col data
	Cols []string
	// Rows table data rows
	Rows []interface{}
	// HasBorder show border line
	HasBorder bool
	// RowBorder show row border
	RowBorder bool
	// HeadBorder show head border
	HeadBorder bool
	// WrapBorder wrap border for table
	WrapBorder bool
}

Table a cli Table show

func NewTable

func NewTable(title string) *Table

NewTable

func (*Table) Format

func (t *Table) Format() string

type Title

type Title struct {
	Title     string
	Formatter func(t *Title) string
}

Title definition

func NewTitle

func NewTitle(title string) *Title

NewTitle instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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