complete

package
v3.54.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package complete implements the `task __complete` protocol consumed by the shell wrappers. It mirrors cobra v2 so a future migration stays cheap.

Index

Constants

View Source
const (
	FlagNoAliases      = "--no-aliases"
	FlagNoDescriptions = "--no-descriptions"
)

Control flags the shell wrappers prepend to the __complete invocation.

View Source
const CommandName = "__complete"

Variables

This section is empty.

Functions

func Complete

func Complete(e *task.Executor, fs *pflag.FlagSet, args []string, opts Options) ([]Suggestion, Directive)

e may be nil when the Taskfile failed to load; flag completion still works.

func IsActive

func IsActive() bool

func NeedsTaskfile

func NeedsTaskfile(args []string, fs *pflag.FlagSet) bool

func Words

func Words() []string

Words returns the command line being completed: the args after __complete.

func Write

func Write(w io.Writer, suggs []Suggestion, dir Directive)

The trailing `:<directive>` line is emitted even with zero suggestions.

Types

type Directive

type Directive int

Directive mirrors cobra's ShellCompDirective bitfield, emitted as `:<n>`.

const (
	DirectiveDefault Directive = 0
	// Never emitted: a failed Taskfile load still leaves flags worth completing.
	DirectiveError         Directive = 1 << 0
	DirectiveNoSpace       Directive = 1 << 1
	DirectiveNoFileComp    Directive = 1 << 2
	DirectiveFilterFileExt Directive = 1 << 3
	DirectiveFilterDirs    Directive = 1 << 4
	DirectiveKeepOrder     Directive = 1 << 5
)

type Options

type Options struct {
	NoAliases      bool
	NoDescriptions bool
}

Named after the control flags, so the zero value is the standard set.

func ParseOptions

func ParseOptions(args []string) (Options, []string)

Only leading flags are consumed; a `--no-aliases` typed later is left alone.

type Suggestion

type Suggestion struct {
	Value       string
	Description string
}

Jump to

Keyboard shortcuts

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