Documentation
¶
Overview ¶
Package slashmatch is what a slash line offers as it is typed: the commands a fragment finds anywhere in their names, their aliases and their descriptions, ranked by alpha's tiers (an exact word, then the start of one, then anywhere, a description after every name), the skills after the commands by how much they were used, and what may come after a command's name as its usage writes it: the fixed words of its subcommands and arguments, and the holes its feature fills with live values. It reads nothing
Index ¶
- Constants
- func Fields(fields []string, query string, offset float64) float64
- func Normalize(query string) string
- func Score(item Item, query string) float64
- func Stack(first string, tokens []string, skill func(token string) (key string, ok bool)) ([]string, bool)
- func Tokens(value string) []string
- func Words(argument string) (done []string, typing string)
- type Hit
- type Item
- type Kind
- type Slot
Constants ¶
const Limit = 30
Most rows of commands, and of skills, a search offers
const MaxStacked = 5
Most skills one line loads, the first among them, as alpha stacks them
Variables ¶
This section is empty.
Functions ¶
func Score ¶
Tier of an entry against a normalized query: its name, label and aliases from 0, its description from 3; infinity on a miss
func Stack ¶
func Stack(first string, tokens []string, skill func(token string) (key string, ok bool)) ([]string, bool)
Skills a skill's line loads: the first, then each token after its name that names a skill, as skill finds it; true while every token names a skill not named before and the line may stack one more, MaxStacked counting the first
Types ¶
type Hit ¶
An entry the typed fragment finds, with its tier, lower first, and the alias it found it by when an alias matched better than the name
func Rank ¶
Entries the fragment typed after the slash finds, as alpha's list ranks them. A fragment of nothing browses: every command of icebath in the order given, the first Limit of the others, then the skills by use and name with those shipped with icebath and never used left out. A fragment searches: the entries it finds by tier, those of one tier in the order given, the first Limit of the commands, then the first Limit of the skills by tier, use and name
type Item ¶
type Item struct {
// Without its slash
Name string
Aliases []string
// What the row shows in place of the name, when it shows something else
Label string
// What it does, a phrase
About string
Kind Kind
// A skill shipped with icebath, which a list browsing every command leaves out until it was used
Bundled bool
// How often it was used, the more used first among the skills of one tier
Uses int64
}
One entry of the slash list
type Kind ¶
type Kind int
What an entry of the slash list is
const ( // One of icebath's own commands, every one of which a list browsing every command shows Command Kind = iota // A command a person, an extension or a project brings, which a list browsing every command shows the first of alone Extra // A command that loads a skill or a bundle of skills, listed after the commands Skill )