sxcli.devSimple Extensible CLI

sxcli.dev/completion/bash

go
go
import "sxcli.dev/completion/bash"

Package bash registers the completionbash System applet: bash completion for the importing binary. Blank-import to link it, like a log sink:

code
text
import _ "sxcli.dev/completion/bash"

Installation (documented by --script's output too):

code
text
eval "$(mybin completionbash --script)"

The generated script is deliberately dumb: it forwards bash's raw completion state and every interpretation — dropping the command word, slicing at the cursor, reassembling the =-tokens bash splits apart, basename dispatch — happens here, in testable Go.

Index#

Constants#

ID is the package's public handle: name it in a composition's Accept to include bash completion in the binary.

go
go
const ID = "sxcli.dev/completion/bash"

type Completionsrc#

Completion is the completionbash System applet. It consumes the core's Introspector (by concrete type, cold like any service) and answers two operations: --script emission and completion queries.

go
go
type Completion struct {
    // I is the core's composition truth; the closure containing it is
    // never ejected, and only completion invocations pay that.
    I *fw.Introspector `inject:""`
    // contains filtered or unexported fields
}

func (*Completion) Configuredsrc#

go
go
func (c *Completion) Configured() error

Configured validates nothing: the query fields are per-invocation transport with no illegal states the parser does not already refuse.

func (*Completion) Runsrc#

go
go
func (c *Completion) Run() int

Run answers the operation selected by the arguments: --script emission, or a completion query. Queries always exit 0 — a completion must never look like a failure.