completion

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: CC0-1.0 Imports: 15 Imported by: 1

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