powershell

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package powershell renders completion results as the JSON payload consumed by the generated registration snippet and generates the Register-ArgumentCompleter snippets for the wire protocol (docs/completion-wire-protocol.md).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(toComplete string, directives wire.Directives, candidates []wire.Candidate) string

Format renders candidates and directives in the powershell framing: the export JSON schema plus a per-candidate "sgr" field, with the presentation fields pre-composed for the snippet's CompletionResult mapping. "value" carries the insertion text (quoted when it contains whitespace or metacharacters, with a trailing space unless the nospace rules apply); "display" carries the ListItemText content ("display (description)" normally, the bare display in tooltip mode); "description" carries the ToolTip content (the clamped description in tooltip mode, a single space otherwise). Styled segments are wrapped in backtick-escaped SGR sequences when color is enabled. Candidates with an empty value are dropped: they have no insertion text. toComplete is accepted for seam symmetry and ignored: the framing is position-independent.

func Snippet

func Snippet(name string, aliases []string, _ string) string

Snippet renders the PowerShell registration script for the given command name and aliases (docs/completion-wire-protocol.md): the single-command form defines one completer function and registers it for the command name (plus its .exe variant, active on Windows and commented out elsewhere); the multi-command form assigns one completer scriptblock (invoking the binary under the name the user typed, .exe suffix stripped) shared by one registration line per name and alias. The completer collects the cursor-truncated command elements (quotes stripped, PowerShell's tokenization), drops the program name, and feeds the words to the binary's __complete entry point; the JSON payload is piped through ConvertFrom-Json into CompletionResult objects. An empty result set returns "" so PowerShell's default file completion is suppressed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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