completion

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCompgenCommandHandler

func NewCompgenCommandHandler(runner *interp.Runner) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc

NewCompgenCommandHandler creates a new ExecHandler for the compgen command

func NewCompleteCommandHandler

func NewCompleteCommandHandler(completionManager *CompletionManager) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc

NewCompleteCommandHandler creates a new ExecHandler for the complete command

Types

type CompletionFunction

type CompletionFunction struct {
	Name   string
	Runner *interp.Runner
}

CompletionFunction represents a bash completion function

func NewCompletionFunction

func NewCompletionFunction(name string, runner *interp.Runner) *CompletionFunction

NewCompletionFunction creates a new CompletionFunction

func (*CompletionFunction) Execute

func (f *CompletionFunction) Execute(ctx context.Context, args []string) ([]string, error)

Execute runs the completion function with the given arguments

type CompletionManager

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

CompletionManager manages command completion specifications

func NewCompletionManager

func NewCompletionManager() *CompletionManager

NewCompletionManager creates a new CompletionManager

func (*CompletionManager) AddSpec

func (m *CompletionManager) AddSpec(spec CompletionSpec)

AddSpec adds or updates a completion specification

func (*CompletionManager) ExecuteCompletion

func (m *CompletionManager) ExecuteCompletion(ctx context.Context, runner *interp.Runner, spec CompletionSpec, args []string) ([]string, error)

ExecuteCompletion executes a completion specification for a given command line and returns the list of possible completions

func (*CompletionManager) GetSpec

func (m *CompletionManager) GetSpec(command string) (CompletionSpec, bool)

GetSpec retrieves a completion specification

func (*CompletionManager) ListSpecs

func (m *CompletionManager) ListSpecs() []CompletionSpec

ListSpecs returns all completion specifications

func (*CompletionManager) RemoveSpec

func (m *CompletionManager) RemoveSpec(command string)

RemoveSpec removes a completion specification

type CompletionManagerInterface

type CompletionManagerInterface interface {
	GetSpec(command string) (CompletionSpec, bool)
	ExecuteCompletion(ctx context.Context, runner *interp.Runner, spec CompletionSpec, args []string) ([]string, error)
}

CompletionManagerInterface defines the interface for completion management

type CompletionSpec

type CompletionSpec struct {
	Command string
	Type    CompletionType
	Value   string   // function name or wordlist
	Options []string // additional options like -o dirname
}

CompletionSpec represents a completion specification for a command

type CompletionType

type CompletionType string

CompletionType represents the type of completion

const (
	// WordListCompletion represents word list based completion (-W option)
	WordListCompletion CompletionType = "W"
	// FunctionCompletion represents function based completion (-F option)
	FunctionCompletion CompletionType = "F"
)

type ShellCompletionProvider

type ShellCompletionProvider struct {
	CompletionManager CompletionManagerInterface
	Runner            *interp.Runner
}

ShellCompletionProvider implements shellinput.CompletionProvider using the shell's CompletionManager

func NewShellCompletionProvider

func NewShellCompletionProvider(manager CompletionManagerInterface, runner *interp.Runner) *ShellCompletionProvider

NewShellCompletionProvider creates a new ShellCompletionProvider

func (*ShellCompletionProvider) GetCompletions

func (p *ShellCompletionProvider) GetCompletions(line string, pos int) []string

GetCompletions returns completion suggestions for the current input line

func (*ShellCompletionProvider) GetHelpInfo added in v0.23.0

func (p *ShellCompletionProvider) GetHelpInfo(line string, pos int) string

GetHelpInfo returns help information for special commands like #! and #/

Jump to

Keyboard shortcuts

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