common

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package common code

Index

Constants

This section is empty.

Variables

View Source
var FromInvokedAction func(action interface{}) (Meta, RawValues)

FromInvokedAction provides access to RawValues within an InvokedAction. It is intended for testing purposes in Sandbox (circumventing dependency issues).

Functions

func IsDash

func IsDash(cmd *cobra.Command) bool

IsDash checks if command contains a dash disabling flag parsing

example action positional1 -- dash1 dash2

Types

type ByDisplay

type ByDisplay []RawValue

ByDisplay alias to filter by display.

func (ByDisplay) Len

func (a ByDisplay) Len() int

func (ByDisplay) Less

func (a ByDisplay) Less(i, j int) bool

func (ByDisplay) Swap

func (a ByDisplay) Swap(i, j int)

type ByRune

type ByRune []rune

func (ByRune) Len

func (r ByRune) Len() int

func (ByRune) Less

func (r ByRune) Less(i, j int) bool

func (ByRune) Swap

func (r ByRune) Swap(i, j int)

type ByValue

type ByValue []RawValue

ByValue alias to filter by value.

func (ByValue) Len

func (a ByValue) Len() int

func (ByValue) Less

func (a ByValue) Less(i, j int) bool

func (ByValue) Swap

func (a ByValue) Swap(i, j int)

type Group

type Group struct {
	Cmd *cobra.Command
}

func (Group) Style

func (g Group) Style() string

func (Group) Tag

func (g Group) Tag() string

type Messages

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

func (*Messages) Add

func (m *Messages) Add(s string)

func (Messages) Get

func (m Messages) Get() []string

func (Messages) Integrate

func (m Messages) Integrate(values RawValues, prefix string) RawValues

func (Messages) IsEmpty

func (m Messages) IsEmpty() bool

func (Messages) MarshalJSON

func (m Messages) MarshalJSON() ([]byte, error)

func (*Messages) Merge

func (m *Messages) Merge(other Messages)

func (*Messages) Suppress

func (m *Messages) Suppress(expr ...string) error

func (*Messages) UnmarshalJSON

func (m *Messages) UnmarshalJSON(data []byte) (err error)

type Meta

type Meta struct {
	Messages Messages      `json:"messages"`
	Nospace  SuffixMatcher `json:"nospace"`
	Usage    string        `json:"usage"`
}

func (*Meta) Merge

func (m *Meta) Merge(other Meta)

type Mock

type Mock struct {
	Dir     string
	Replies map[string]string
}

func NewMock

func NewMock(t t) *Mock

func (Mock) CacheDir

func (m Mock) CacheDir() string

func (Mock) WorkDir

func (m Mock) WorkDir() string

type RawValue

type RawValue struct {
	Value       string `json:"value"`
	Display     string `json:"display"`
	Description string `json:"description,omitempty"`
	Style       string `json:"style,omitempty"`
	Tag         string `json:"tag,omitempty"`
}

RawValue represents a completion candidate.

func (RawValue) TrimmedDescription

func (r RawValue) TrimmedDescription() string

TrimmedDescription returns the trimmed description.

type RawValues

type RawValues []RawValue

RawValues is an alias for []RawValue.

func RawValuesFrom

func RawValuesFrom(values ...string) RawValues

RawValuesFrom creates RawValues from given values.

func (RawValues) Decolor

func (r RawValues) Decolor() RawValues

Decolor clears style for all values.

func (RawValues) EachTag

func (r RawValues) EachTag(f func(tag string, values RawValues))

func (RawValues) Filter

func (r RawValues) Filter(values ...string) RawValues

Filter filters values.

func (RawValues) FilterPrefix

func (r RawValues) FilterPrefix(prefix string) RawValues

FilterPrefix filters values with given prefix.

func (RawValues) Retain

func (r RawValues) Retain(values ...string) RawValues

Retain retains given values.

func (RawValues) Unique

func (r RawValues) Unique() RawValues

type SuffixMatcher

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

func (*SuffixMatcher) Add

func (sm *SuffixMatcher) Add(suffixes ...rune)

func (SuffixMatcher) MarshalJSON

func (sm SuffixMatcher) MarshalJSON() ([]byte, error)

func (SuffixMatcher) Matches

func (sm SuffixMatcher) Matches(s string) bool

func (*SuffixMatcher) Merge

func (sm *SuffixMatcher) Merge(other SuffixMatcher)

func (*SuffixMatcher) UnmarshalJSON

func (sm *SuffixMatcher) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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