completion

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: CC0-1.0 Imports: 15 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

completion

The completion package extends serpent to allow applications to generate rich auto-completions.

Protocol

The completion scripts call out to the serpent command to generate completions. The convention is to pass the exact args and flags (or cmdline) of the in-progress command with a COMPLETION_MODE=1 environment variable. That environment variable lets the command know to generate completions instead of running the command. By default, completions will be generated based on available flags and subcommands. Additional completions can be added by supplying a CompletionHandlerFunc on an Option or Command.

Documentation

Index

Constants

View Source
const (
	ShellBash       string = "bash"
	ShellFish       string = "fish"
	ShellZsh        string = "zsh"
	ShellPowershell string = "powershell"
)

Variables

This section is empty.

Functions

func FileHandler

func FileHandler(filter func(info os.FileInfo) bool) serpent.CompletionHandlerFunc

FileHandler returns a handler that completes file names, using the given filter func, which may be nil.

func InstallShellCompletion

func InstallShellCompletion(shell Shell) error

func ShellOptions

func ShellOptions(choice *string) *serpent.Enum

Types

type Shell

type Shell interface {
	Name() string
	InstallPath() (string, error)
	WriteCompletion(io.Writer) error
	ProgramName() string
}

func Bash

func Bash(goos string, programName string) Shell

func DetectUserShell

func DetectUserShell(programName string) (Shell, error)

func Fish

func Fish(goos string, programName string) Shell

func Powershell

func Powershell(goos string, programName string) Shell

func ShellByName

func ShellByName(shell, programName string) (Shell, error)

func Zsh

func Zsh(goos string, programName string) Shell

Jump to

Keyboard shortcuts

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