cli

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FunctionNameDefaultVersion = "AcDefaultVersionFn"
	FunctionNameDefaultExit    = "AcDefaultExitFn"
)

Variables

This section is empty.

Functions

func BuiltinLanguages

func BuiltinLanguages() []string

func GetLanguage

func GetLanguage(preferredLanguage string, mapping map[string][]string) (languages []string)

func PrintProgress

func PrintProgress(task *CalculateTask)

func RegisterHandler

func RegisterHandler(name string, handler Handler)

func RegisterInjector

func RegisterInjector(name string, injector Injector)

Types

type ApplicationConfig

type ApplicationConfig struct {
	Version           string                   `json:"version" yaml:"version"`
	Copyright         string                   `json:"copyright" yaml:"copyright"`
	ReleasedAt        string                   `json:"released_at" yaml:"released_at"`
	CaseSensitive     bool                     `json:"case_sensitive" yaml:"case_sensitive"`
	CliPrefix         string                   `json:"cli_prefix" yaml:"cli_prefix"`
	PreferredLanguage string                   `json:"preferred_language" yaml:"preferred_language"`
	Commands          map[string]CommandConfig `json:"commands" yaml:"commands,omitempty"`
	Debug             bool                     `json:"debug" yaml:"debug"`
	LanguageMapping   map[string][]string      `json:"language_mapping" yaml:"language_mapping"`
}

type CalculateTask

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

func NewCalculateTask

func NewCalculateTask(taskName string, totalTasks int, tickInterval time.Duration, options ...progressbar.Option) *CalculateTask

func (*CalculateTask) RefreshName

func (task *CalculateTask) RefreshName(name string)

func (*CalculateTask) RefreshProgress

func (task *CalculateTask) RefreshProgress(progress int)

type CommandConfig

type CommandConfig struct {
	Type         string                   `json:"type" yaml:"type"`
	Handler      string                   `json:"handler" yaml:"handler"`
	Examples     string                   `json:"examples" yaml:"examples"`
	Descriptions []DescriptionConfig      `json:"descriptions" yaml:"descriptions"`
	Commands     map[string]CommandConfig `json:"commands" yaml:"commands"`
}

type CommandLine

type CommandLine interface {
	Execute(options ...prompt.Option)
	Matcher(document prompt.Document) (suggestions []prompt.Suggest, startChar, endChar pstrings.RuneNumber)
}

func NewCli

func NewCli(cfg ApplicationConfig) CommandLine

type DescriptionConfig

type DescriptionConfig struct {
	Language string `json:"lang" yaml:"lang"`
	Name     string `json:"name" yaml:"name"`
	Text     string `json:"text" yaml:"text"`
}

type ExampleType

type ExampleType = string

type Handler

type Handler func(input *Input)

func DefaultExitHandler

func DefaultExitHandler() Handler

func DefaultHandler

func DefaultHandler() Handler

func GetHandler

func GetHandler(name string) (handler Handler, ok bool)

func NoCommandHandler

func NoCommandHandler() Handler

type HandlerItem

type HandlerItem struct {
	Name    string
	Handler Handler
}

type HandlerNotFoundError

type HandlerNotFoundError struct {
	CommandPath string
	HandlerName string
	// contains filtered or unexported fields
}

func (HandlerNotFoundError) Error

func (e HandlerNotFoundError) Error() string

type Injector

type Injector func(input *Input) (result []TranslationSet)

func GetInjector

func GetInjector(name string) (injector Injector, ok bool)

func StaticInjector

func StaticInjector(statics []TranslationSet) Injector

type InjectorItem

type InjectorItem struct {
	Name     string
	Injector Injector
}

type InjectorNotFoundError

type InjectorNotFoundError struct {
	CommandPath  string
	InjectorName string
	// contains filtered or unexported fields
}

func (InjectorNotFoundError) Error

func (e InjectorNotFoundError) Error() string

type Input

type Input struct {
	Params   http.Params
	FullText string
	Language []string
}

type NodeType

type NodeType = string
const (
	NodeTypeCommand NodeType = "command"
	NodeTypeOption  NodeType = "option"
)

type Params

type Params struct {
	http.Params
}

func (Params) Set

func (p Params) Set(key, value string)

type TranslatedItem

type TranslatedItem struct {
	Language           string `json:"language" yaml:"language"`
	DisplayKey         string `json:"display_key" yaml:"display_key"`
	DisplayDescription string `json:"display_description" yaml:"display_description"`
}

type TranslationSet

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

func (*TranslationSet) GetTranslation

func (ts *TranslationSet) GetTranslation(languages ...string) (key, description string)

func (*TranslationSet) InitTranslations

func (ts *TranslationSet) InitTranslations(items []TranslatedItem)

Jump to

Keyboard shortcuts

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