autocomplete

package
v0.0.0-...-73c8340 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CursorMarker = "$0"

CursorMarker is the string that is used to denote the position of the cursor in the formatted output string.

Functions

func Autocomplete

func Autocomplete(input string, cursorPos int, action cloudpb.AutocompleteActionType, s Suggester, orgID uuid.UUID, clusterUID string) (string, bool, []*cloudpb.TabSuggestion, error)

Autocomplete returns a formatted string and suggestions for the given input.

Types

type Command

type Command struct {
	TabStops       []*TabStop
	Executable     bool
	HasValidScript bool
}

Command represents an executable command.

func ParseIntoCommand

func ParseIntoCommand(input string, s Suggester, orgID uuid.UUID, clusterUID string) (*Command, error)

ParseIntoCommand takes user input and attempts to parse it into a valid command with suggestions.

func (*Command) ToFormatString

func (cmd *Command) ToFormatString(action cloudpb.AutocompleteActionType, s Suggester, orgID uuid.UUID, clusterUID string) (string, []*cloudpb.TabSuggestion)

ToFormatString converts a command to a formatted string with tab indexes, such as: ${1:run} ${2: px/svc_info}

type ElasticSuggester

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

ElasticSuggester provides suggestions based on the given index in Elastic.

func NewElasticSuggester

func NewElasticSuggester(client *elastic.Client, mdIndex, scriptIndex string, pc profilepb.ProfileServiceClient) (*ElasticSuggester, error)

NewElasticSuggester creates a suggester based on an elastic index.

func (*ElasticSuggester) GetSuggestions

func (e *ElasticSuggester) GetSuggestions(reqs []*SuggestionRequest) ([]*SuggestionResult, error)

GetSuggestions get suggestions for the given input using Elastic. It returns the suggestions, whether or not more matches exist, and an error.

func (*ElasticSuggester) UpdateScriptBundle

func (e *ElasticSuggester) UpdateScriptBundle(br *script.BundleManager)

UpdateScriptBundle updates the script bundle used to populate the suggester's script suggestions.

type Suggester

type Suggester interface {
	// GetSuggestions does a fuzzy match on the given input.
	GetSuggestions(reqs []*SuggestionRequest) ([]*SuggestionResult, error)
}

Suggester is responsible for providing suggestions.

type Suggestion

type Suggestion struct {
	Name           string
	Desc           string
	Score          float64 // A score representing how closely the suggestion matches the given input.
	Kind           cloudpb.AutocompleteEntityKind
	ArgNames       []string // If the suggestion is a script, the args that the script takes.
	ArgKinds       []cloudpb.AutocompleteEntityKind
	MatchedIndexes []int64
	State          cloudpb.AutocompleteEntityState
}

Suggestion is a suggestion for a token.

type SuggestionRequest

type SuggestionRequest struct {
	OrgID        uuid.UUID
	ClusterUID   string
	Input        string
	AllowedKinds []cloudpb.AutocompleteEntityKind
	AllowedArgs  []cloudpb.AutocompleteEntityKind
}

SuggestionRequest is a request for autocomplete suggestions.

type SuggestionResult

type SuggestionResult struct {
	Suggestions          []*Suggestion
	ExactMatch           bool
	HasAdditionalMatches bool
}

SuggestionResult contains results for an autocomplete request.

type TabStop

type TabStop struct {
	Value          string
	Kind           cloudpb.AutocompleteEntityKind
	Valid          bool
	Suggestions    []*Suggestion
	ContainsCursor bool
	ArgName        string
}

TabStop represents a tab stop in a command.

Directories

Path Synopsis
Package mock_autocomplete is a generated GoMock package.
Package mock_autocomplete is a generated GoMock package.

Jump to

Keyboard shortcuts

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