completion

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

completion/data.go

completion/powershell.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashGenerator

type BashGenerator struct{}

func (*BashGenerator) Generate

func (g *BashGenerator) Generate(programName string, data CompletionData) string

type CompletionData

type CompletionData struct {
	Commands            []string
	Flags               []FlagPair
	CommandFlags        map[string][]FlagPair
	FlagValues          map[string][]CompletionValue
	CommandDescriptions map[string]string
}

CompletionData holds all the data needed for shell completion

type CompletionFileInfo added in v1.8.1

type CompletionFileInfo struct {
	Prefix    string // Some shells require specific prefixes
	Extension string // File extension if required
	Comment   string // Documentation about the naming convention
}

CompletionFileInfo holds shell-specific naming conventions

type CompletionPaths added in v1.8.1

type CompletionPaths struct {
	Primary   string // Main completion path
	Fallback  string // Alternative path if primary isn't available
	Extension string // File extension for completion script (if any)
	Comment   string // Documentation about the path choice
}

CompletionPaths holds information about completion script locations

type CompletionValue

type CompletionValue struct {
	Pattern     string // The regex pattern
	Description string // Human-readable description
}

CompletionValue represents a possible value for a flag with its description

type FishGenerator

type FishGenerator struct{}

func (*FishGenerator) Generate

func (g *FishGenerator) Generate(programName string, data CompletionData) string

type FlagPair added in v1.8.2

type FlagPair struct {
	Short       string
	Long        string
	Description string
	Type        FlagType
}

FlagPair represents a short and long version of the same flag

type FlagType added in v1.8.2

type FlagType int

FlagType mirrors goopt.OptionType but keeps packages decoupled

const (
	// Single denotes a flag accepting a string value
	FlagTypeSingle FlagType = 0
	// Chained denotes a flag accepting a string value which should be evaluated as a list
	FlagTypeChained FlagType = 1
	// Standalone denotes a boolean flag (does not accept a value)
	FlagTypeStandalone FlagType = 2
	// File denotes a flag which is evaluated as a path
	FlagTypeFile FlagType = 3
)

type Generator

type Generator interface {
	Generate(programName string, data CompletionData) string
}

func GetGenerator

func GetGenerator(shell string) Generator

type Manager added in v1.8.3

type Manager struct {
	Shell       string          // The shell to generate completion for
	ProgramName string          // The name of the program to generate completion for
	Paths       CompletionPaths // The paths where the completion script will be saved
	// contains filtered or unexported fields
}

Manager is used to manage and save completion scripts for a given shell

func NewManager added in v1.8.3

func NewManager(shell, programName string) (*Manager, error)

NewManager creates a completion manager which can be used to manage and save completion scripts for a given shell

func (*Manager) Accept added in v1.8.3

func (cm *Manager) Accept(data CompletionData)

Accept generates and stores the completion script from the provided data

func (*Manager) HasExistingCompletion added in v1.9.5

func (cm *Manager) HasExistingCompletion() (string, bool)

HasExistingCompletion checks if a completion script is already installed Returns the path to the existing completion file and whether it exists

func (*Manager) IsShellSupported added in v1.9.5

func (cm *Manager) IsShellSupported() bool

IsShellSupported returns whether the current shell has completion generation support

func (*Manager) Save added in v1.8.8

func (cm *Manager) Save() (path string, err error)

Save saves the previously generated completion script

type PowerShellGenerator

type PowerShellGenerator struct{}

func (*PowerShellGenerator) Generate

func (g *PowerShellGenerator) Generate(programName string, data CompletionData) string

type ZshGenerator

type ZshGenerator struct{}

func (*ZshGenerator) Generate

func (g *ZshGenerator) Generate(programName string, data CompletionData) string

Jump to

Keyboard shortcuts

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