bash_completion

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 6 Imported by: 1

README

bash_completion

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Complete

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

func New

func New(program string, completer Completer, options ...Option) *Complete

func (*Complete) GetEnv

func (r *Complete) GetEnv(k EnvName) (val string, err error)

func (*Complete) Run

func (b *Complete) Run(word, preceedingWord string) error

bash passes word and preceedingWord to the complete command, but it is not used, nor needed

func (*Complete) SetEnv

func (r *Complete) SetEnv(k EnvName, val string) error

type Completer

type Completer interface {
	Complete(args []string, partial string) (suggestions []string, finished bool, err error)
}

type EnvName

type EnvName string
const (
	ENV_COMP_LINE       EnvName = "COMP_LINE"       // The current command line.
	ENV_COMP_POINT      EnvName = "COMP_POINT"      // The index of the current cursor position relative to the beginning of the current command.
	ENV_COMP_KEY        EnvName = "COMP_KEY"        // The key (or final key of a key sequence) used to invoke the current completion function.
	ENV_COMP_TYPE       EnvName = "COMP_TYPE"       // Set to an integer value corresponding to the type of completion attempted that caused a completion function to be called: TAB, for normal completion, ‘?’, for listing completions after successive tabs, ‘!’, for listing alternatives on partial word completion, ‘@’, to list completions if the word is not unmodified, or ‘%’, for menu completion.
	ENV_COMP_WORDS      EnvName = "COMP_WORDS"      // An array variable consisting of the individual words in the current command line. The line is split into words as Readline would split it, using COMP_WORDBREAKS as described above.
	ENV_COMP_CWORD      EnvName = "COMP_CWORD"      // An index into ${COMP_WORDS} of the word containing the current cursor position.
	ENV_COMP_WORDBREAKS EnvName = "COMP_WORDBREAKS" // The set of characters that the Readline library treats as word separators when performing word completion. If COMP_WORDBREAKS is unset, it loses its special properties, even if it is subsequently reset.
)

func (EnvName) String

func (e EnvName) String() string

type Option

type Option func(*Complete)

func WithEnv

func WithEnv(key EnvName, val string) Option

func WithLogger

func WithLogger(logger io.Writer) Option

func WithStdout

func WithStdout(newStdout io.Writer) Option

Jump to

Keyboard shortcuts

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