compromise

package
v0.0.0-...-e19543c Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Beep

func Beep()

func StringMatches

func StringMatches(s, prefix string) bool

Types

type Candidate

type Candidate interface {
	CandidateList

	// Value returns a text to be completed. e.g. "-f", "--file", "filename.txt"
	Value() string

	// Raw returns whether it's a "raw" candidate -- e.g. whether it needs not to be escaped.
	// e.g. if a candidate value is `$HOME`, and if it's not a raw candidate, then `\$HOME` will be
	// inserted to command line. On the other hand, if it's raw, `$HOME` will be inserted.
	Raw() bool

	// Hidden returns whether it's a "hidden" candidate. TODO Explain
	Hidden() bool

	// Continues returns whether a candidate needs not to be followed by a space when inserted.
	Continues() bool

	// Force returns whether a candidate always needs to be included in the completion list
	// even if the current token is not a prefix of this candidate.
	Force() bool

	// Help returns a help string for a candidate.
	Help() string

	Serialize(wr *bufio.Writer)

	Deserialize(rd *bufio.Reader) error

	SetValue(value string) Candidate
	SetRaw(raw bool) Candidate
	SetHidden(hidden bool) Candidate
	SetContinues(continues bool) Candidate
	SetForce(force bool) Candidate
	SetHelp(help string) Candidate
}

Candidate represents a single candidate

func Deserialize

func Deserialize(rd *bufio.Reader) (Candidate, error)

func NewCandidate

func NewCandidate() Candidate

type CandidateList

type CandidateList interface {
	GetCandidate(prefix string) []Candidate

	Matches(word string) bool

	MatchesFully(word string) bool
}

CandidateList represents a list of Candidate's.

func LazyCandidates

func LazyCandidates(generator func(prefix string) []Candidate) CandidateList

LazyCandidates generates a CandidateList from a given list of Candidate's.

func OpenCandidates

func OpenCandidates(candidates ...Candidate) CandidateList

OpenCandidates generates an "open" CandidateList from a given list of Candidate's. it's "open" because candidates are considered to be non-exhaustive and any strings are considered to be potential matches.

func StrictCandidates

func StrictCandidates(candidates ...Candidate) CandidateList

StrictCandidates generates an "strict" CandidateList from a given list of Candidate's. it's "strict" because candidates are considered to be exhaustive and other strings aren't considered to be potential matches.

type CandidateListGenerator

type CandidateListGenerator func(ctx CompleteContext, args []string) CandidateList

type CompleteContext

type CompleteContext interface {
	// Command returns the unescaped target executable command name.
	Command() string
	// RawCommand returns the raw target executable command name.
	RawCommand() string

	// WordAtCursor returns the unescaped word at cursor.
	WordAtCursor(offset int) string
	// RawWordAtCursor returns the raw word at cursor.
	RawWordAtCursor(offset int) string

	// WordAt returns the unescaped word at pc.
	WordAt(offset int) string
	// RawWordAt returns the raw word at pc.
	RawWordAt(offset int) string

	// BeforeCursor returns whether pc is after the cursor index.
	BeforeCursor() bool
	// AfterCursor returns whether pc is after the cursor index.
	AfterCursor() bool
	// AtCursor returns whether pc is equal to the cursor index.
	AtCursor() bool
}

CompleteContext is a context for complete functions.

type Directives

type Directives struct {
	TabWidth  int    `json:"tab"`  // Tabs in a spec is assumed to be this many spaces.
	StartLine int    `json:"line"` // USed to override the number of a spec string
	Filename  string `json:"file"` // Filename where a spec is defined
}

func ExtractDirectives

func ExtractDirectives(spec string) *Directives

ExtractDirectives options in a form of json from the first line of the spec string.

func NewDirectives

func NewDirectives() *Directives

func (*Directives) JSON

func (d *Directives) JSON() string

func (*Directives) SetFilename

func (d *Directives) SetFilename(filename string) *Directives

func (*Directives) SetSourceLocation

func (d *Directives) SetSourceLocation() *Directives

func (*Directives) SetStartLine

func (d *Directives) SetStartLine(lineNumber int) *Directives

func (*Directives) Tab

func (d *Directives) Tab(tabWidth int) *Directives

func (*Directives) UnmarshalJSON

func (d *Directives) UnmarshalJSON(jsonString string) error

type SourceLocation

type SourceLocation interface {
	SourceLocation() (string, int, int)
}

type SpecError

type SpecError struct {
	Location SourceLocation
	Message  string
}

func NewSpecError

func NewSpecError(location SourceLocation, message string) SpecError

func NewSpecErrorf

func NewSpecErrorf(location SourceLocation, format string, args ...interface{}) SpecError

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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