Documentation
¶
Overview ¶
Package completion provides tab completion functionality for the gsh REPL. It manages completion specifications, integrates with bash's compgen, and provides file and word completion capabilities.
Package completion provides tab completion functionality for the gsh REPL. It manages completion specifications, integrates with bash's compgen, and provides file and word completion capabilities.
Index ¶
- func NewCompgenCommandHandler(runner *interp.Runner) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc
- type CompletionFunction
- type CompletionSpec
- type CompletionType
- type Provider
- type RunnerProvider
- type SpecRegistry
- func (r *SpecRegistry) AddSpec(spec CompletionSpec)
- func (r *SpecRegistry) ExecuteCompletion(ctx context.Context, runner *interp.Runner, spec CompletionSpec, args []string) ([]string, error)
- func (r *SpecRegistry) GetSpec(command string) (CompletionSpec, bool)
- func (r *SpecRegistry) ListSpecs() []CompletionSpec
- func (r *SpecRegistry) RemoveSpec(command string)
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.
Types ¶
type CompletionFunction ¶
CompletionFunction represents a bash completion function.
func NewCompletionFunction ¶
func NewCompletionFunction(name string, runner *interp.Runner) *CompletionFunction
NewCompletionFunction creates a new CompletionFunction.
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 Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the CompletionProvider interface for the REPL input. It parses user input and routes completion requests to the appropriate source (specs, files, commands, macros, etc.)
func NewProvider ¶
func NewProvider(runnerProvider RunnerProvider) *Provider
NewProvider creates a new completion Provider.
func (*Provider) GetCompletions ¶
GetCompletions returns completion suggestions for the current input line.
func (*Provider) GetHelpInfo ¶
GetHelpInfo returns help information for special commands like #! and #/.
func (*Provider) RegisterSpec ¶
func (p *Provider) RegisterSpec(spec CompletionSpec)
RegisterSpec adds or updates a completion specification for a command.
func (*Provider) UnregisterSpec ¶
UnregisterSpec removes a completion specification for a command.
type RunnerProvider ¶
type RunnerProvider interface {
// Runner returns the underlying mvdan/sh runner.
Runner() *interp.Runner
// GetPwd returns the current working directory.
GetPwd() string
}
RunnerProvider is an interface for getting the shell runner and current directory. This allows the completion provider to work with different executor implementations.
type SpecRegistry ¶
type SpecRegistry struct {
// contains filtered or unexported fields
}
SpecRegistry stores and executes command completion specifications. It manages specs like "git completes with add/commit/push" and executes them.
func NewSpecRegistry ¶
func NewSpecRegistry() *SpecRegistry
NewSpecRegistry creates a new SpecRegistry.
func (*SpecRegistry) AddSpec ¶
func (r *SpecRegistry) AddSpec(spec CompletionSpec)
AddSpec adds or updates a completion specification.
func (*SpecRegistry) ExecuteCompletion ¶
func (r *SpecRegistry) 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 (*SpecRegistry) GetSpec ¶
func (r *SpecRegistry) GetSpec(command string) (CompletionSpec, bool)
GetSpec retrieves a completion specification.
func (*SpecRegistry) ListSpecs ¶
func (r *SpecRegistry) ListSpecs() []CompletionSpec
ListSpecs returns all completion specifications.
func (*SpecRegistry) RemoveSpec ¶
func (r *SpecRegistry) RemoveSpec(command string)
RemoveSpec removes a completion specification.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package completers provides specialized completion sources for different types of input.
|
Package completers provides specialized completion sources for different types of input. |