completion

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package completion serves dynamic shell completions (organization slugs, namespaces, data source and job ids, language codes) from the API.

Completion must never get in the way of typing: every lookup has a one second budget, results are cached for a minute per profile and organization, nothing prompts, and any failure simply offers nothing.

Index

Constants

View Source
const Budget = time.Second

Budget is how long one lookup may take.

View Source
const TTL = time.Minute

TTL is how long a cached answer is reused.

Variables

This section is empty.

Functions

func Bind

func Bind(f *clictx.Flags)

Bind registers the root command's flags. NewRootCmd calls it.

func Flag

func Flag(key string, fetch Fetcher) cobra.CompletionFunc

Flag returns a cobra completion function for a flag value.

func Func

func Func(key string, maxArgs int, fetch Fetcher) cobra.CompletionFunc

Func returns a cobra completion function for positional arguments that serves fetch's candidates for the first maxArgs arguments (0: all).

func Lookup

func Lookup(cmd *cobra.Command, key, prefix string, fetch Fetcher) []cobra.Completion

Lookup returns the cached or freshly fetched candidates that start with prefix. It never fails: an error or a timeout yields nothing.

Types

type Fetcher

type Fetcher func(cmd *cobra.Command) ([]cobra.Completion, error)

Fetcher looks the candidates up. Each is a value, optionally followed by a tab and a description ("id\tname").

Jump to

Keyboard shortcuts

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