slashmatch

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Limit = 30

Most rows of commands, and of skills, a search offers

View Source
const MaxStacked = 5

Most skills one line loads, the first among them, as alpha stacks them

Variables

This section is empty.

Functions

func Fields

func Fields(fields []string, query string, offset float64) float64

Best tier of any of the fields plus the offset, infinity when none finds the query

func Normalize

func Normalize(query string) string

A slash query as it is matched: trimmed, its leading slashes gone, lower case

func Score

func Score(item Item, query string) float64

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

func Tokens

func Tokens(value string) []string

The search tokens of a field: the whole of it in lower case, then each of its words

func Words

func Words(argument string) (done []string, typing string)

The words of a slash line after its name: those done, and the one being typed, empty after a space

Types

type Hit

type Hit struct {
	Item
	Score float64
	Alias string
}

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

func Rank(items []Item, fragment string) []Hit

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
)

type Slot

type Slot struct {
	Word string
	Hole string
}

What may come at the place of a slash line's argument: a word written in the command's usage, or a hole its feature fills, by its name

func Next

func Next(usage string, words []string) []Slot

What the usage offers after the words typed: every word and hole that may come next, in the order the usage writes them, each once. A word typed that the usage has no place for leaves nothing to offer

Jump to

Keyboard shortcuts

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