ctk

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 14 Imported by: 7

README

ctk

cui toolkit

命令行工具

Documentation

Index

Constants

View Source
const (
	YYYY                   = "2006"
	YYYY_MM                = "2006-01"
	YYYY_MM_DD             = "2006-01-02"
	YYYY_MM_DD_HH          = "2006-01-02 15"
	YYYY_MM_DD_HH_MM       = "2006-01-02 15:04"
	YYYY_MM_DD_HH_MM_SS    = "2006-01-02 15:04:05"
	YYYY_MM_DD_HH_MM_SS_MS = "2006-01-02 15:04:05.000"
	HH_MM_SS               = "15:04:05"
	HH_MM_SS_MS            = "15:04:05.000"
)

Variables

This section is empty.

Functions

func BuildFormat

func BuildFormat(info HelpInfo) string

BuildFormat

func CheckIfError

func CheckIfError(err error)

CheckIfError assert err is nil

func GetInternalIP added in v1.1.0

func GetInternalIP() string

func Home

func Home() (string, error)

Home eg: /home/test

func IsFileExist

func IsFileExist(path string) bool

IsFileExist relative or absolute path

func OpenBrowser

func OpenBrowser(url string) error

func PrintParams

func PrintParams(format string, flagColor Color, params []ParamVO)

PrintParams

func PrintTitle

func PrintTitle(command string, helpInfo HelpInfo)

PrintTitle

func PrintWithColorful

func PrintWithColorful()

PrintWithColorful

func ReadCsvFile

func ReadCsvFile(filename string) [][]string

func ReadFileLines

func ReadFileLines(filename string,
	filterFunc func(string) bool,
	mapFunc func(string) interface{}) []interface{}

ReadFileLines filter and map

func ReadFileLinesNoFilter

func ReadFileLinesNoFilter(filename string, mapFunc func(string) interface{}) []interface{}

ReadFileLinesNoFilter only map

Types

type ArrayFlags

type ArrayFlags []string

func (*ArrayFlags) Set

func (i *ArrayFlags) Set(value string) error

Set 方法是flag.Value接口, 设置flag Value的方法. 通过多个flag指定的值, 所以我们追加到最终的数组上.

func (*ArrayFlags) String

func (i *ArrayFlags) String() string

Value ...

type BufferWriter

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

func NewWriter

func NewWriter(filePath string, truncate bool) (*BufferWriter, error)

func NewWriterIgnoreError

func NewWriterIgnoreError(filePath string, truncate bool) *BufferWriter

func (*BufferWriter) Close

func (w *BufferWriter) Close()

func (*BufferWriter) Write

func (w *BufferWriter) Write(val []byte) (nn int, err error)

func (*BufferWriter) WriteLine

func (w *BufferWriter) WriteLine(val string) (nn int, err error)

func (*BufferWriter) WriteString

func (w *BufferWriter) WriteString(val string) (nn int, err error)

type Color

type Color string
const (
	Red         Color = "\033[0;31m"
	Green       Color = "\033[0;32m"
	Yellow      Color = "\033[0;33m"
	Blue        Color = "\033[0;34m"
	Purple      Color = "\033[0;35m"
	Cyan        Color = "\033[0;36m"
	White       Color = "\033[0;37m"
	LightRed    Color = "\033[0;91m"
	LightGreen  Color = "\033[0;92m"
	LightYellow Color = "\033[0;93m"
	LightBlue   Color = "\033[0;94m"
	LightPurple Color = "\033[0;95m"
	LightCyan   Color = "\033[0;96m"
	LightWhite  Color = "\033[0;97m"
	End         Color = "\033[0m"
)

func (Color) Print

func (t Color) Print(content string) string

Print content with color

func (Color) PrintNoEnd

func (t Color) PrintNoEnd(content string) string

Print content with color no end

func (Color) Printf

func (t Color) Printf(format string, a ...interface{}) string

Printf content with color and format

func (Color) Println

func (t Color) Println(content string) string

Print content with color

func (Color) String

func (t Color) String() string

type HelpInfo

type HelpInfo struct {
	Version       string
	BuildVersion  string
	Description   string
	SingleFlagLen int
	DoubleFlagLen int
	ValueLen      int
	Flags         []ParamVO
	Options       []ParamVO
	Args          []ParamVO
}

func (HelpInfo) Parse

func (helpInfo HelpInfo) Parse()

func (HelpInfo) PrintHelp

func (helpInfo HelpInfo) PrintHelp()

PrintHelp info msg

type ParamInfo

type ParamInfo struct {
	Verb    string
	Param   string
	Comment string
	Handler func(params []string)
}

type ParamVO

type ParamVO struct {
	Short   string
	Long    string
	Value   string
	Comment string

	DefaultVar interface{}

	BoolType    bool
	BoolVar     *bool
	Float64Type bool
	Float64Var  *float64
	IntType     bool
	IntVar      *int
	Int64Type   bool
	Int64Var    *int64
	StringType  bool
	StringVar   *string
	UintType    bool
	UintVar     *uint
}

type Set

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

func NewSet

func NewSet(s ...interface{}) *Set

func (*Set) Add

func (s *Set) Add(val ...interface{})

func (*Set) Adds added in v1.0.9

func (s *Set) Adds(set *Set)

func (*Set) Clear

func (s *Set) Clear()

func (*Set) Contains

func (s *Set) Contains(val interface{}) bool

func (*Set) Difference added in v1.0.9

func (s *Set) Difference(set *Set) *Set

差集

func (*Set) Intersect added in v1.0.9

func (s *Set) Intersect(set *Set) *Set

交集

func (*Set) Intersection

func (s *Set) Intersection(set *Set) *Set

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

func (*Set) Len

func (s *Set) Len() int

func (*Set) Loop

func (s *Set) Loop(action func(interface{}))

func (*Set) Remove

func (s *Set) Remove(val interface{})

func (*Set) Supplementary added in v1.0.9

func (s *Set) Supplementary(set *Set) *Set

补集 余集

func (*Set) Union added in v1.0.9

func (s *Set) Union(set *Set) *Set

并集

type Value

type Value interface {
	String() string
	Set(string) error
}

Jump to

Keyboard shortcuts

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