completion

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LooksLikeMinecraft

func LooksLikeMinecraft(image, invocation string, features map[string][]string) bool

LooksLikeMinecraft reports whether server metadata suggests a Minecraft egg.

func LooksLikeMinecraftEnv

func LooksLikeMinecraftEnv(image, invocation string, features map[string][]string, env map[string]string) bool

LooksLikeMinecraftEnv is like LooksLikeMinecraft but also checks egg environment variables (e.g. MINECRAFT_VERSION, SERVER_JARFILE) which are more reliable than the unresolved {{SERVER_JARFILE}} startup template.

func NormalizeCursor

func NormalizeCursor(line string, cursor int) int

NormalizeCursor clamps cursor into [0, len(line)].

Types

type ArgSpec

type ArgSpec struct {
	Values []string `json:"values,omitempty"`
	Any    bool     `json:"any,omitempty"`
}

ArgSpec is either a fixed set of literal values or free-form input (Any).

type Command

type Command struct {
	// Args[i] is the completion spec for the i-th argument after the command name.
	Args []ArgSpec `json:"args"`
}

Command describes sequential argument completions for a command.

type Request

type Request struct {
	ID     string `json:"id"`
	Line   string `json:"line"`
	Cursor int    `json:"cursor"`
}

Request is the inbound suggest-command payload.

type Response

type Response struct {
	ID          string   `json:"id"`
	Line        string   `json:"line"`
	Cursor      int      `json:"cursor"`
	Start       int      `json:"start"`
	End         int      `json:"end"`
	Suggestions []string `json:"suggestions"`
}

Response is returned to the panel for Tab completion.

func Suggest

func Suggest(tree *Tree, line string, cursor int) Response

Suggest walks tree for the partial line and returns prefix-filtered matches plus the byte range [Start, End) that the panel should replace.

Token rules (prefix = line[:cursor]):

  • "/gam" → command names matching "gam"
  • "/gamemode " → first-arg values
  • "/gamemode c" → first-arg values matching "c"
  • "/gamemode survival " → second-arg values (if defined)

type Tree

type Tree struct {
	Commands map[string]Command `json:"commands"`
}

Tree is a static CLI completion tree for a server console. Commands map the first token (without a leading slash) to argument specs.

func Builtin

func Builtin(name string) *Tree

Builtin returns a named built-in completion profile, or nil if unknown. Profiles are optional conveniences; any egg can ship a full Tree via process_configuration.completion instead.

func Minecraft

func Minecraft() *Tree

Minecraft is a built-in completion profile for common vanilla / Paper-style console commands. Eggs for any app should prefer shipping their own tree via process_configuration.completion; this profile is only a convenience.

func ResolveTree

func ResolveTree(explicit *Tree, features map[string][]string, image, invocation string) *Tree

ResolveTree picks a completion tree for a server console.

Order:

  1. Explicit egg/process tree (any app) — wins when non-empty
  2. Egg feature "console_completion" listing built-in profile names
  3. Auto-detect a known built-in (currently Minecraft) as a convenience

func ResolveTreeEnv

func ResolveTreeEnv(explicit *Tree, features map[string][]string, image, invocation string, env map[string]string) *Tree

ResolveTreeEnv is ResolveTree with egg environment variables for auto-detect.

Jump to

Keyboard shortcuts

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