Documentation
¶
Overview ¶
Package commandsuggest records commands explicitly authored by CLI presenters. It never discovers commands by inspecting arbitrary output.
Index ¶
- Variables
- func Configure(root *cli.Command) func()
- func Invalidate(command *cli.Command)
- func OpenPickerInput(output *os.File) (*os.File, error)
- func Pick(ctx context.Context, input, output *os.File, candidates []Candidate, ...) (string, error)
- func Record(command *cli.Command, text string) string
- func RecordFor(command *cli.Command, shell, text string) string
- func RecordLabel(command *cli.Command, label, target string) string
- func RecordTo(command *cli.Command, output io.Writer, text string) string
- func RenderText(text string, suggestions []string, render func(string) string) string
- func SetRecorder(command *cli.Command, recorder Recorder)
- func WriteLine(command *cli.Command, output io.Writer, text string) error
- type Candidate
- type Recorder
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = errors.New("command selection canceled")
ErrCanceled means that the picker returned no selection.
Functions ¶
func Configure ¶
Configure enables the optional shell transport and returns its idempotent flush. The shell supplies an already-open private file, never a pathname to create.
func Invalidate ¶
Invalidate discards this invocation's suggestions after a failed presentation. Already emitted links must never resolve through a partial command capture.
func OpenPickerInput ¶
OpenPickerInput owns a readable duplicate of the supplied physical terminal. Candidate stdin can be a pipe, and shell widgets may lack a controlling tty.
func Pick ¶
func Pick(ctx context.Context, input, output *os.File, candidates []Candidate, title string, integration bool) (string, error)
Pick runs the shared local selector. It returns data and never executes it. Input and output belong to the foreground terminal, separate from data pipes.
func RecordLabel ¶
RecordLabel displays a label whose insertion target is an explicit command. Registration occurs when the presenter renders the label, never during setup.
func RenderText ¶
RenderText renders literal spans declared by the presenter. It does not discover suggestions in prose. Replacements use one pass, so nested commands and text returned by render cannot create new spans.
func SetRecorder ¶
SetRecorder attaches a recorder without replacing the command's output writer.
Types ¶
type Candidate ¶
Candidate is a declared command, never an instruction to execute it.
func Catalog ¶
func Catalog(root *cli.Command, invocation string, children func(*cli.Command) []*cli.Command, examples func(*cli.Command, string) []Candidate) []Candidate
Catalog derives discovery from the current command tree on every invocation. The callbacks reuse help's ordering and authored examples without rendering help.
func ReadCandidates ¶
ReadCandidates accepts the bounded, single-line suggestion transport only. Reject the whole input on malformed data; never silently select from a partial list.