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 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 WithinOneEdit(a, b string) bool
- func WriteLine(command *cli.Command, output io.Writer, text string) error
- type Candidate
- type Recorder
- type Selection
- type TaskPhrase
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 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.
func WithinOneEdit ¶ added in v1.51.0
WithinOneEdit reports whether a and b differ by at most one insertion, deletion, substitution, or transposition of adjacent characters.
Types ¶
type Candidate ¶
type Candidate struct {
Command string
Description string
// contains filtered or unexported fields
}
Candidate is a declared command, never an instruction to execute it.
func Catalog ¶
func Catalog(root *cli.Command, invocation string, taskPhrases map[string][]TaskPhrase, 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 Example ¶ added in v1.51.0
Example keeps the exact shell invocation for selection and its arguments for discovery.
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.
type Recorder ¶
Recorder receives explicit suggestions and their human-readable destination. An empty shell means that the suggestion applies to any supported shell.
type Selection ¶ added in v1.51.0
Selection describes the user's explicit picker action.
func Pick ¶
func Pick(ctx context.Context, input, output *os.File, candidates []Candidate, title string, integration bool, setupPrompt string) (Selection, 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.
type TaskPhrase ¶ added in v1.51.0
TaskPhrase describes a search for an installed command. Keep the default word order when reversing the words could change the requested operation.