Documentation
¶
Index ¶
- Constants
- Variables
- func AnyOf(s *Source, choices []string) (string, error)
- func Bool(s *Source) (bool, error)
- func Datetime(s *Source) (time.Time, error)
- func Duration(s *Source) (time.Duration, error)
- func EOF(s *Source) error
- func Float(s *Source) (float64, error)
- func Float32(s *Source) (float32, error)
- func Integer(s *Source) (int, error)
- func Objective(s *Source) (string, error)
- func ScanObjective(s *Source) (string, error)
- func String(s *Source) (string, error)
- func Validate(input string) error
- func Value(s *Source) (any, error)
- func Verb(s *Source) (string, error)
- type AddEdge
- type DeleteEdge
- type DeleteVertex
- type GetEdge
- type GetVertex
- type Illuminate
- type PutEdge
- type PutVertex
- type ScanEdges
- type ScanVertices
- type Source
Constants ¶
const HelpText = `` /* 957-byte string literal not displayed */
HelpText is the per-verb grammar reference printed by the `help` verb (#436). Single source of truth for the Go REPL; the TypeScript port keeps a byte-equivalent copy at `admin/app/lib/cli/verbs.ts` `HELP_TEXT`, and the shared fixture `admin/test/cli-grammar/verbs.json` exercises both parsers against the bare `help` verb.
The kwarg enums and defaults below MUST stay in lockstep with `IlluminateParam`'s `IlluminateAlgorithms` / `IlluminateObjectives` / `IlluminateWeightings` sets and the corresponding TS parser.
Variables ¶
var ( Verbs = []string{ "get", "put", "add", "delete", "scan", "illuminate", "help", "exit", } Objectives = []string{ "vertex", "edge", } // ScanObjectives are the plural-form objectives accepted by the // `scan` verb. They intentionally do NOT overlap with `Objectives` // (singular vertex/edge), which the get/put/delete/add verbs use, so // `get vertices` and `scan vertex` are both clean parse errors. ScanObjectives = []string{ "vertices", "edges", } // IlluminateAlgorithms / IlluminateObjectives / IlluminateWeightings // are the canonical sets the REPL accepts for the keyword arguments of // the modernised illuminate verb (#410). The keyword form replaces the // legacy positional grammar (neighbor / spt_* / mst_*) entirely. IlluminateAlgorithms = []string{"none", "mst", "spt"} IlluminateObjectives = []string{"min", "max"} IlluminateWeightings = []string{"raw", "tfidf"} ErrNotFound = errors.New("not found") ErrNotEOF = errors.New("not EOF") )
var ( ErrOutOfIndex = errors.New("out of index") // ErrUnterminatedString is returned by NewSource when the input // contains an unmatched single- or double-quote opener. See #438. ErrUnterminatedString = errors.New("unterminated string literal") )
var ErrParse = errors.New("parse error")
Functions ¶
func AnyOf ¶
AnyOf returns the canonical lowercase choice that matches the next token case-insensitively, or ErrNotFound. The returned value is always one of the entries in `choices` (not the raw token), so downstream switches can compare against the canonical form. This mirrors the Go REPL's existing ToLower-on-dispatch convention and keeps argument tokens (vertex keys, edge endpoints, illuminate seeds) free of case mangling \u2014 see #437.
func ScanObjective ¶ added in v0.9.0
Types ¶
type AddEdge ¶
func AddEdgeParam ¶
type DeleteEdge ¶
func DeleteEdgeParam ¶
func DeleteEdgeParam(s *Source) (*DeleteEdge, error)
type DeleteVertex ¶
type DeleteVertex struct {
Key string
}
func DeleteVertexParam ¶
func DeleteVertexParam(s *Source) (*DeleteVertex, error)
type GetEdge ¶
func GetEdgeParam ¶
type Illuminate ¶
type Illuminate struct {
Seed string
Step int
K int
Algorithm string // "none" | "mst" | "spt" (default: "none")
Objective string // "min" | "max" (default: "max")
Weighting string // "raw" | "tfidf" (default: "raw")
Prefix string // vertex-key prefix filter; "" (default) = no filter (#604)
}
func IlluminateParam ¶
func IlluminateParam(s *Source) (*Illuminate, error)
IlluminateParam parses the modernised illuminate grammar (#410, #604):
illuminate <seed> <step> <k> [algorithm=none|mst|spt] [objective=min|max] [weighting=raw|tfidf] [prefix=<string>]
The keyword arguments may appear in any order and any subset. The three closed-set axes default to the strongest-edge behaviour (algorithm=none, objective=max, weighting=raw); objective defaults to max so a bare illuminate keeps the top-k strongest neighbours and the per-hop pruning matches the reduction direction (#560). prefix is free-text and defaults to empty (no frontier filter; #604). Unknown keyword names, malformed `key=value` tokens, closed-set values outside the canonical set above, or an empty prefix= value are rejected with a descriptive error so the REPL can surface a usage hint.
type PutEdge ¶
func PutEdgeParam ¶
type PutVertex ¶
func PutVertexParam ¶
type ScanEdges ¶ added in v0.9.0
func ScanEdgesParam ¶ added in v0.9.0
ScanEdgesParam parses `scan edges <tail-prefix> [limit]`. The objective token ("edges") has already been consumed by the caller. An empty tail-prefix is permitted (scans every tail), matching the server's ScanEdges semantics where both prefixes default to empty.
type ScanVertices ¶ added in v0.9.0
ScanVertices / ScanEdges back the `scan vertices` / `scan edges` REPL verbs that mirror the admin web CLI shape (#411). Limit is optional; 0 means "use the server default".
func ScanVerticesParam ¶ added in v0.9.0
func ScanVerticesParam(s *Source) (*ScanVertices, error)
ScanVerticesParam parses `scan vertices <prefix> [limit]`. The objective token ("vertices") has already been consumed by the caller; this function only reads the prefix and optional limit. An empty prefix is rejected because an unbounded vertex scan from the REPL is almost never what the operator meant.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
func NewSource ¶
NewSource tokenises the input into a Source. The grammar (#438):
token = bareword | double-quoted | single-quoted
bareword = first char ∉ {whitespace,'"',"'"}, continues until next whitespace.
Quotes inside a bareword are kept verbatim.
double-quoted = "..." with C-style escapes \", \\, \n, \r, \t.
single-quoted = '...' verbatim (no escapes).
Quoting is only special at the start of a token. Unterminated quotes (or unknown backslash sequences inside a double-quoted token) return ErrUnterminatedString or a parse error. On any error the returned Source is still valid (empty token stream) so callers that ignore the error do not deref a nil pointer.
func NewSourceFromTokens ¶ added in v0.16.0
NewSourceFromTokens builds a Source directly from already-split tokens, skipping the quote-aware tokeniser entirely. It exists so the one-shot CLI verbs (`lantern get vertex <key>`, etc.) can feed cobra's shell-split argv straight into the same grammar the REPL parses from a raw line — the shell already performed the word/quote splitting, so a second pass through tokenise() would be both redundant and lossy (a value containing spaces would be re-split). The verb token is expected to be the first element, mirroring `Verb(s)` on a NewSource stream.