completion

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 5 Imported by: ? modules, 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

Overview

Package completion provides shell completion scripts and dynamic completion candidates for the ssd CLI.

The shell scripts (bash/zsh/fish) are tiny shims that delegate to `ssd __complete <prev-tokens>` for every TAB press. The hidden __complete command parses the tokens already on the command line and prints newline-separated candidates on stdout; the shell does the final prefix filtering against the partial word at the cursor.

Keeping the scripts thin means there is one source of truth for the command/sub-command layout (this package, in Go) instead of three copies that drift apart per shell.

Index

Constants

This section is empty.

Variables

View Source
var ServiceCommands = map[string]bool{
	"deploy": true, "up": true, "update": true, "down": true, "rm": true,
	"restart": true, "rollback": true, "status": true, "ps": true,
	"logs": true, "config": true, "scale": true,
}

ServiceCommands take a single optional service positional argument (or none, meaning "all services"). Completion offers the configured service names from ssd.yaml.

View Source
var TopLevelCommands = []string{
	"init", "migrate", "deploy", "up", "update", "down", "rm", "restart",
	"rollback", "status", "ps", "logs", "config", "env", "secret",
	"prune", "scale", "provision", "skill", "completion",
	"version", "help",
}

TopLevelCommands lists every command users can invoke directly via `ssd <command>`. Hidden helpers (e.g. __complete) are intentionally omitted so they do not surface in TAB completion.

Functions

func ActivationHint

func ActivationHint(shell, path string) string

ActivationHint returns shell-specific instructions the user needs to follow once for the completion file to be picked up. Returns "" when no action is needed (e.g. fish auto-loads its completions dir).

func Complete

func Complete(prev []string, services []string)

Complete prints completion candidates for the given list of already-typed tokens (NOT including the binary name and NOT including the partial word at the cursor). One candidate per line.

The shell filters the output against the cursor's current prefix, so this function returns ALL plausible candidates at the position it infers from prev. It never returns an error: any I/O failure (e.g. missing ssd.yaml) collapses to "no candidates", which is the only sensible behavior during a TAB press.

func DetectShell

func DetectShell() string

DetectShell returns the user's shell ("bash", "zsh", or "fish") based on $SHELL, or "" if unrecognised. On Windows we always return "" since none of the supported shells are first-class there.

func Install

func Install(shell string) (string, error)

Install writes the completion script for shell to its conventional per-user path and returns the path it wrote to. Existing files are overwritten (re-installing on upgrade should be a no-op).

func InstallPath

func InstallPath(shell string) (string, error)

InstallPath returns the absolute path the completion script for shell will be written to by Install. Exported so callers (tests, help text) can show it without writing anything.

func Script

func Script(shell string) (string, error)

Script returns the completion script for the given shell. Returns an error for unknown shells.

func SupportedShells

func SupportedShells() []string

SupportedShells returns the list of shells Install/Script accept, in a stable order suitable for help text.

Types

This section is empty.

Jump to

Keyboard shortcuts

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