Documentation
¶
Index ¶
- Constants
- Variables
- func AbsoluteShellPath(path string) bool
- func ExecuteShellCompletion(ctx context.Context, cmd *cli.Command) error
- func FishPackagePickerScript() ([]byte, error)
- func IsPickerInstalled(ctx context.Context, options PickerInstallation) (bool, error)
- func IsSuggestionsInstalled(ctx context.Context, options SuggestionInstallation) (bool, error)
- func OutputCompletionScript(ctx context.Context, cmd *cli.Command) error
- func PathPrecedesSuggestions(file *os.File, size int64, profile, line, executable string) bool
- func RenderShellSuggestions(shell CompletionStyle, appName string) (string, error)
- func SuggestionLoader(options SuggestionInstallation) (string, error)
- func WithPickerSetupLock(ctx context.Context, directory string, change func() error) error
- func WithSuggestionSetup(ctx context.Context, shell CompletionStyle, automatic, remove bool, ...) (skipped bool, err error)
- type CompletionResult
- type CompletionStyle
- type PickerInstallResult
- func InstallPicker(ctx context.Context, options PickerInstallation) (PickerInstallResult, error)
- func InstallSuggestions(ctx context.Context, options SuggestionInstallation) (PickerInstallResult, error)
- func RemovePicker(ctx context.Context, options PickerInstallation) (PickerInstallResult, error)
- func RemoveSuggestions(ctx context.Context, options SuggestionInstallation) (PickerInstallResult, error)
- type PickerInstallation
- type ShellCompletion
- type ShellCompletionBehavior
- type ShellProfilePaths
- type SuggestionInstallation
- type SuggestionStatus
Constants ¶
const ( ShellCompletionBehaviorDefault ShellCompletionBehavior = iota ShellCompletionBehaviorFile = 10 ShellCompletionBehaviorNoComplete = 11 ShellCompletionBehaviorFileOrStdin = 12 )
Variables ¶
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 ExecuteShellCompletion ¶
func FishPackagePickerScript ¶ added in v1.37.0
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 PathPrecedesSuggestions ¶ added in v1.51.0
PathPrecedesSuggestions recognizes the installer's PATH selection immediately before an intact, final insertion loader. A later user instruction must win the normal PATH check, even if it follows an older, valid loader.
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 SuggestionLoader ¶ added in v1.51.0
func SuggestionLoader(options SuggestionInstallation) (string, error)
SuggestionLoader returns the same startup code as the managed profile. The installer checks the final line before loading it in its calling shell.
func WithPickerSetupLock ¶ added in v1.36.0
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.
func WithSuggestionSetup ¶ added in v1.51.0
func WithSuggestionSetup(ctx context.Context, shell CompletionStyle, automatic, remove bool, change func() error) (skipped bool, err error)
WithSuggestionSetup serializes the installer with explicit enable and removal. The preference follows the user's shell even when XDG_CONFIG_HOME changes.
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
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 ¶
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
// Preserve an existing binding preference when enabling insertion from Explore.
KeepBindings bool
// Source the loader after the installer has restored PATH.
AfterShellSetup 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)
Source Files
¶
- autocomplete.go
- picker_fish_package.go
- picker_install.go
- picker_install_ancestry.go
- picker_install_ancestry_unix.go
- picker_install_cleanup.go
- picker_install_identity_other.go
- picker_install_identity_unix.go
- picker_install_links_unix.go
- picker_install_lock_unix.go
- picker_install_metadata.go
- picker_install_metadata_linux.go
- picker_install_metadata_unix.go
- picker_install_permissions_other.go
- picker_install_recovery.go
- picker_install_recovery_directory.go
- picker_install_recovery_directory_unix.go
- picker_install_rename.go
- picker_install_rename_linux.go
- picker_install_security_labels.go
- picker_script.go
- shell_profiles.go
- shell_suggestions.go
- suggestions_install.go
- suggestions_profile_path.go
- suggestions_script.go