Help us shape the future of Go! Take the 2026 Go Developer Survey

autocomplete

package
v1.42.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShellCompletionBehaviorDefault    ShellCompletionBehavior = iota
	ShellCompletionBehaviorFile                               = 10
	ShellCompletionBehaviorNoComplete                         = 11
)

Variables

View Source
var ErrPickerAtomicRenameUnsupported = errors.New("atomic no-replace rename is not supported")

ErrPickerAtomicRenameUnsupported identifies an unavailable atomic no-replace operation. It does not describe other operations on the same filesystem.

Functions

func AbsoluteShellPath added in v1.40.3

func AbsoluteShellPath(path string) bool

func ExecuteShellCompletion

func ExecuteShellCompletion(ctx context.Context, cmd *cli.Command) error

func FishPackagePickerScript added in v1.37.0

func FishPackagePickerScript() ([]byte, error)

FishPackagePickerScript renders the Linux package's vendor_conf.d script. It checks consent at activation and the selected executable at every Tab press.

func IsPickerInstalled added in v1.36.0

func IsPickerInstalled(ctx context.Context, options PickerInstallation) (bool, error)

IsPickerInstalled verifies an intact profile block and an owned script that matches this CLI's current content, without creating files or locking.

func IsSuggestionsInstalled added in v1.40.3

func IsSuggestionsInstalled(ctx context.Context, options SuggestionInstallation) (bool, error)

IsSuggestionsInstalled checks owned startup configuration without writing files. It reads saved settings, so callers need not rediscover the original executable.

func OutputCompletionScript

func OutputCompletionScript(ctx context.Context, cmd *cli.Command) error

func RenderShellSuggestions added in v1.39.0

func RenderShellSuggestions(shell CompletionStyle, appName string) (string, error)

RenderShellSuggestions emits an explicitly requested, session-only shell hook. The hook examines executable spelling, never request arguments or shell input.

func WithPickerSetupLock added in v1.36.0

func WithPickerSetupLock(ctx context.Context, directory string, change func() error) error

WithPickerSetupLock serializes a command's complete setup decision, including all startup profiles and its opt-out preference. Its lock is distinct from the per-file transaction locks used by InstallPicker and RemovePicker.

Types

type CompletionResult

type CompletionResult struct {
	Completions []ShellCompletion
	Behavior    ShellCompletionBehavior
	// FileValuePrefix is emitted only for an assigned file value. Shells use it
	// to distinguish --file=path from a separated path that contains an equals.
	FileValuePrefix string
	// contains filtered or unexported fields
}

func GetCompletions

func GetCompletions(completionStyle CompletionStyle, root *cli.Command, args []string) CompletionResult

type CompletionStyle

type CompletionStyle string
const (
	CompletionStyleZsh        CompletionStyle = "zsh"
	CompletionStyleBash       CompletionStyle = "bash"
	CompletionStylePowershell CompletionStyle = "pwsh"
	CompletionStyleFish       CompletionStyle = "fish"
)

type PickerInstallResult added in v1.36.0

type PickerInstallResult struct {
	Changed    bool
	ScriptPath string
}

func InstallPicker added in v1.36.0

func InstallPicker(ctx context.Context, options PickerInstallation) (PickerInstallResult, error)

InstallPicker persists normal completion and the optional picker hook. The immutable script is committed before the profile; failed profile updates preserve scripts needed by an interrupted profile transaction. Cooperating writers serialize from validation through recovery. External editors do not share these locks: displaced profiles are retained, and publication never replaces an entry created by an editor during the transaction.

func InstallSuggestions added in v1.40.3

func InstallSuggestions(ctx context.Context, options SuggestionInstallation) (PickerInstallResult, error)

InstallSuggestions uses the same profile transaction and locks as picker setup. Its separate namespace preserves picker configuration and cleanup ownership.

func RemovePicker added in v1.36.0

func RemovePicker(ctx context.Context, options PickerInstallation) (PickerInstallResult, error)

RemovePicker removes only an intact managed block and its verified script. Modified blocks or scripts are preserved and reported for manual inspection.

func RemoveSuggestions added in v1.40.3

func RemoveSuggestions(ctx context.Context, options SuggestionInstallation) (PickerInstallResult, error)

RemoveSuggestions does not need the executable to remain installed.

type PickerInstallation added in v1.36.0

type PickerInstallation struct {
	Shell      CompletionStyle
	Directory  string
	Profile    string
	OptOutPath string // Optional shared marker for managed fish activation.
	// contains filtered or unexported fields
}

PickerInstallation contains only caller-selected paths. Shell discovery and consent belong to the command layer. Profile must be the startup file that this shell actually reads.

func SelectShellProfiles added in v1.40.3

func SelectShellProfiles(shell, override string, paths ShellProfilePaths) ([]PickerInstallation, error)

Selection only inspects file names. Ownership, symlinks, concurrent changes, and safe file creation are checked by autocomplete when installing.

func ShellRemovalProfiles added in v1.40.3

func ShellRemovalProfiles(targets []PickerInstallation, profileOverride string) []PickerInstallation

type ShellCompletion

type ShellCompletion struct {
	Name  string
	Usage string
}

func NewShellCompletion

func NewShellCompletion(name string, usage string) ShellCompletion

type ShellCompletionBehavior

type ShellCompletionBehavior int

type ShellProfilePaths added in v1.40.3

type ShellProfilePaths struct{ Home, Config, FishConfig, Zdotdir string }

ShellProfilePaths supplies explicit paths for shell startup-file selection.

type SuggestionInstallation added in v1.40.3

type SuggestionInstallation struct {
	Shell      CompletionStyle
	Directory  string
	Profile    string
	Executable string
	DoubleTab  bool
}

SuggestionInstallation selects a profile and a logical executable path. Executable deliberately retains symlinks, so package upgrades remain visible.

type SuggestionStatus added in v1.40.3

type SuggestionStatus struct {
	Installed   bool
	NeedsUpdate bool
	Executable  string
	ScriptPath  string
	DoubleTab   bool
}

SuggestionStatus describes verified persistent configuration, not current bindings.

func InspectSuggestions added in v1.40.3

func InspectSuggestions(ctx context.Context, options SuggestionInstallation) (SuggestionStatus, error)

Jump to

Keyboard shortcuts

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