cli

package
v0.0.0-...-b48d157 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ANSI_CODE_RESET string = "\x1b[0m"

	ANSI_CODE_BOLD            string = "\x1b[1m"
	ANSI_CODE_BOLD_RESET      string = "\x1b[22m"
	ANSI_CODE_DIM             string = "\x1b[2m"
	ANSI_CODE_DIM_RESET       string = "\x1b[22m"
	ANSI_CODE_ITALIC          string = "\x1b[3m"
	ANSI_CODE_ITALIC_RESET    string = "\x1b[23m"
	ANSI_CODE_UNDERLINE       string = "\x1b[4m"
	ANSI_CODE_UNDERLINE_RESET string = "\x1b[24m"
	ANSI_CODE_BLINK           string = "\x1b[5m"
	ANSI_CODE_BLINK_RESET     string = "\x1b[25m"
	ANSI_CODE_REVERSE         string = "\x1b[7m"
	ANSI_CODE_REVERSE_RESET   string = "\x1b[27m"
	ANSI_CODE_HIDE            string = "\x1b[8m"
	ANSI_CODE_HIDE_RESET      string = "\x1b[28m"
	ANSI_CODE_STRIKE          string = "\x1b[9m"
	ANSI_CODE_STRIKE_RESET    string = "\x1b[29m"

	ANSI_CODE_FOREGROUND_RESET   string = "\x1b[0m"
	ANSI_CODE_BACKGROUND_RESET   string = "\x1b[0m"
	ANSI_CODE_FOREGROUND_BLACK   string = "\x1b[30m"
	ANSI_CODE_BACKGROUND_BLACK   string = "\x1b[40m"
	ANSI_CODE_FOREGROUND_RED     string = "\x1b[31m"
	ANSI_CODE_BACKGROUND_RED     string = "\x1b[41m"
	ANSI_CODE_FOREGROUND_GREEN   string = "\x1b[32m"
	ANSI_CODE_BACKGROUND_GREEN   string = "\x1b[42m"
	ANSI_CODE_FOREGROUND_YELLOW  string = "\x1b[33m"
	ANSI_CODE_BACKGROUND_YELLOW  string = "\x1b[43m"
	ANSI_CODE_FOREGROUND_BLUE    string = "\x1b[34m"
	ANSI_CODE_BACKGROUND_BLUE    string = "\x1b[44m"
	ANSI_CODE_FOREGROUND_MAGENTA string = "\x1b[35m"
	ANSI_CODE_BACKGROUND_MAGENTA string = "\x1b[45m"
	ANSI_CODE_FOREGROUND_CYAN    string = "\x1b[36m"
	ANSI_CODE_BACKGROUND_CYAN    string = "\x1b[46m"
	ANSI_CODE_FOREGROUND_WHITE   string = "\x1b[37m"
	ANSI_CODE_BACKGROUND_WHITE   string = "\x1b[47m"
	ANSI_CODE_FOREGROUND_DEFAULT string = "\x1b[39m"
	ANSI_CODE_BACKGROUND_DEFAULT string = "\x1b[49m"

	ANSI_CODE_ERASE_SCREEN_END   string = "\x1b[0Jm"
	ANSI_CODE_ERASE_SCREEN_START string = "\x1b[1Jm"
	ANSI_CODE_ERASE_SCREEN       string = "\x1b[2Jm"
	ANSI_CODE_ERASE_LINE_END     string = "\x1b[0K"
	ANSI_CODE_ERASE_LINE_START   string = "\x1b[1K"
	ANSI_CODE_ERASE_LINE         string = "\x1b[2K"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args map[string]reflect.Value

func (Args) MarshalJSON

func (self Args) MarshalJSON() ([]byte, error)

func (Args) String

func (self Args) String() string

type Command

type Command struct {
	Name        string                `json:"name"`
	Description string                `json:"description"`
	Params      Params                `json:"params"`
	Disabled    bool                  `json:"disabled"`
	Commands    []Command             `json:"commands"`
	Handler     func(args Args) error `json:"-"`
}

func NewCommand

func NewCommand(name string) Command

func (Command) Run

func (self Command) Run(args ...string) error

func (Command) String

func (self Command) String() string

func (Command) WithCommand

func (self Command) WithCommand(cmd Command) Command

func (Command) WithDescription

func (self Command) WithDescription(description string) Command

func (Command) WithDisabled

func (self Command) WithDisabled(disabled bool) Command

func (Command) WithHandler

func (self Command) WithHandler(handler func(args Args) error) Command

func (Command) WithParams

func (self Command) WithParams(params Params) Command

type Param

type Param interface {
	Type() Primitive
	GetDescription() string
	IsRequired() bool
	Coerce(value string) (any, error)
	Validate(value string) error
}

type Params

type Params map[string]Param

func (Params) Validate

func (self Params) Validate(value ...string) (Args, error)

type Primitive

type Primitive string
const (
	STRING Primitive = "string"
	INT    Primitive = "int"
	FLOAT  Primitive = "float"
	BOOL   Primitive = "bool"
)

type StringParam

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

func String

func String() StringParam

func (StringParam) Coerce

func (self StringParam) Coerce(value string) (any, error)

func (StringParam) Description

func (self StringParam) Description(description string) StringParam

func (StringParam) GetDescription

func (self StringParam) GetDescription() string

func (StringParam) IsRequired

func (self StringParam) IsRequired() bool

func (StringParam) MarshalJSON

func (self StringParam) MarshalJSON() ([]byte, error)

func (StringParam) MaxLength

func (self StringParam) MaxLength(maxLength int) StringParam

func (StringParam) MinLength

func (self StringParam) MinLength(minLength int) StringParam

func (StringParam) Required

func (self StringParam) Required() StringParam

func (StringParam) String

func (self StringParam) String() string

func (StringParam) Type

func (self StringParam) Type() Primitive

func (*StringParam) UnmarshalJSON

func (self *StringParam) UnmarshalJSON(b []byte) error

func (StringParam) Validate

func (self StringParam) Validate(value string) error

type Text

type Text string

func (Text) BlackBackground

func (self Text) BlackBackground() Text

func (Text) BlackForeground

func (self Text) BlackForeground() Text
func (self Text) Blink() Text

func (Text) BlueBackground

func (self Text) BlueBackground() Text

func (Text) BlueForeground

func (self Text) BlueForeground(text string) Text

func (Text) Bold

func (self Text) Bold() Text

func (Text) CyanBackground

func (self Text) CyanBackground() Text

func (Text) CyanForeground

func (self Text) CyanForeground() Text

func (Text) DefaultBackground

func (self Text) DefaultBackground() Text

func (Text) DefaultForeground

func (self Text) DefaultForeground() Text

func (Text) Dim

func (self Text) Dim() Text

func (Text) EraseLine

func (self Text) EraseLine() Text

func (Text) EraseLineEnd

func (self Text) EraseLineEnd() Text

func (Text) EraseLineStart

func (self Text) EraseLineStart() Text

func (Text) EraseScreen

func (self Text) EraseScreen() Text

func (Text) EraseScreenEnd

func (self Text) EraseScreenEnd() Text

func (Text) EraseScreenStart

func (self Text) EraseScreenStart() Text

func (Text) GreenBackground

func (self Text) GreenBackground() Text

func (Text) GreenForeground

func (self Text) GreenForeground() Text

func (Text) Hide

func (self Text) Hide() Text

func (Text) Italic

func (self Text) Italic() Text

func (Text) MagentaBackground

func (self Text) MagentaBackground() Text

func (Text) MagentaForeground

func (self Text) MagentaForeground() Text

func (Text) PadLeft

func (self Text) PadLeft(n int) Text

func (Text) PadRight

func (self Text) PadRight(n int) Text

func (Text) RedBackground

func (self Text) RedBackground() Text

func (Text) RedForeground

func (self Text) RedForeground() Text

func (Text) Reverse

func (self Text) Reverse() Text

func (Text) Strike

func (self Text) Strike() Text

func (Text) String

func (self Text) String() string

func (Text) Underline

func (self Text) Underline() Text

func (Text) WhiteBackground

func (self Text) WhiteBackground() Text

func (Text) WhiteForeground

func (self Text) WhiteForeground() Text

func (Text) YellowBackground

func (self Text) YellowBackground() Text

func (Text) YellowForeground

func (self Text) YellowForeground() Text

Jump to

Keyboard shortcuts

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