Documentation
¶
Index ¶
- Constants
- Variables
- func AnyOf(s *Source, choices []string) (string, error)
- func Bool(s *Source) (bool, error)
- func CoerceValue(raw, typ string) (any, 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 CountVertices
- type DeleteEdge
- type DeletePrefixVertices
- type DeleteVertex
- type EdgePair
- type GetEdge
- type GetVertex
- type Illuminate
- type Keys
- type PutEdge
- type PutVertex
- type ScanEdges
- type ScanVertices
- type Source
Constants ¶
const HelpText = `` /* 1427-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", "count", "delete-prefix", "keys", "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", "ppr"} IlluminateObjectives = []string{"min", "max"} IlluminateWeightings = []string{"raw", "tfidf", "bm25"} 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 CoerceValue ¶ added in v0.18.0
CoerceValue converts a raw CLI value token into a Go value for PutVertex, honouring the optional `type=` override (migrated from the noun-first `vertex put --value-type`). "" / "auto" auto-detects (int→float→bool→RFC3339→string); otherwise the named type is forced and a mismatch is an error. `json` parses the token and re-encodes objects / arrays as a compact JSON string (the wire has no nested value variant); json scalars pass through as their natural Go type.
func ScanObjective ¶ added in v0.9.0
Types ¶
type AddEdge ¶
func AddEdgeParam ¶
type CountVertices ¶ added in v0.18.0
type CountVertices struct {
Prefix string
}
CountVertices backs `count vertices <prefix>` — the prefix-cardinality verb migrated from the former `vertex count` subcommand.
func CountVerticesParam ¶ added in v0.18.0
func CountVerticesParam(s *Source) (*CountVertices, error)
CountVerticesParam parses `count vertices <prefix>` — exactly one prefix (migrated from the `vertex count` subcommand). The objective token ("vertices") has already been consumed by the caller.
type DeleteEdge ¶
type DeleteEdge struct {
Pairs []EdgePair
}
DeleteEdge backs `delete edge <tail> <head> [<tail> <head> …]`. Pairs holds one or more (tail, head) pairs (the token count must be even).
func DeleteEdgeParam ¶
func DeleteEdgeParam(s *Source) (*DeleteEdge, error)
DeleteEdgeParam parses `delete edge <tail> <head> [<tail> <head> …]` — one or more (tail, head) pairs (an even, non-zero token count). A single pair deletes one edge; more than one routes to DeleteEdges.
type DeletePrefixVertices ¶ added in v0.18.0
DeletePrefixVertices backs `delete-prefix vertices <prefix> [limit=<n>] [confirm=yes|dry_run=true]` — the destructive prefix delete migrated from `vertex delete-prefix`. Exactly one of Confirm / DryRun must be set (the safety gate); a bare `delete-prefix vertices p` is a usage error.
func DeletePrefixVerticesParam ¶ added in v0.18.0
func DeletePrefixVerticesParam(s *Source) (*DeletePrefixVertices, error)
DeletePrefixVerticesParam parses `delete-prefix vertices <prefix> [limit=<int>] [confirm=yes|dry_run=true]`. Exactly one of confirm=yes or dry_run=true is REQUIRED — the destructive-op safety gate; a bare `delete-prefix vertices p` is a usage error. The objective token ("vertices") has already been consumed by the caller.
type DeleteVertex ¶
type DeleteVertex struct {
Keys []string
}
DeleteVertex backs `delete vertex <key> [<key> …]`. Keys holds one or more keys; the dispatcher forwards a one-element batch to DeleteVertex and a multi-element batch to DeleteVertices.
func DeleteVertexParam ¶
func DeleteVertexParam(s *Source) (*DeleteVertex, error)
DeleteVertexParam parses `delete vertex <key> [<key> …]` — one or more keys. A one-element batch deletes a single vertex; more than one routes to DeleteVertices in the dispatcher.
type GetEdge ¶
func GetEdgeParam ¶
type Illuminate ¶
type Illuminate struct {
Seed string
Step int
K int
Algorithm string // "none" | "mst" | "spt" | "ppr" (default: "none")
Objective string // "min" | "max" (default: "max")
Weighting string // "raw" | "tfidf" | "bm25" (default: "raw")
Prefix string // vertex-key prefix filter; "" (default) = no filter (#604)
RestartProb float32 // PPR restart prob α; 0 (default) = server default 0.15 (#801)
Epsilon float32 // PPR residual threshold ε; 0 (default) = server default 1e-4 (#801)
}
func IlluminateParam ¶
func IlluminateParam(s *Source) (*Illuminate, error)
IlluminateParam parses the modernised illuminate grammar (#410, #604, #801):
illuminate <seed> <step> <k> [algorithm=none|mst|spt|ppr] [objective=min|max] [weighting=raw|tfidf|bm25] [prefix=<string>] [restart_prob=<float>] [epsilon=<float>]
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). restart_prob and epsilon tune the Personalized PageRank algorithm (#801) and default to 0, which the server resolves to α=0.15 / ε=1e-4; they are ignored unless algorithm=ppr. Unknown keyword names, malformed `key=value` tokens, closed-set values outside the canonical set above, an empty prefix= value, or a non-float restart_prob=/epsilon= value are rejected with a descriptive error so the REPL can surface a usage hint.
type Keys ¶ added in v0.17.0
Keys backs the `keys <prefix> [limit]` verb — the Redis-familiar key lister that lists vertex keys under a prefix (keys-only output). Lantern is a prefix-indexed store, so Prefix is a key PREFIX, not a glob. Limit is optional (0 = server default), mirroring ScanVertices.
func KeysParam ¶ added in v0.17.0
KeysParam parses `keys <prefix> [limit]` — the Redis-familiar key lister. Lantern is a prefix-indexed store, so the argument is a key PREFIX (not a glob): `keys user:` lists every vertex key under "user:". A prefix is required; the optional trailing limit caps the page (0 = server default), mirroring ScanVerticesParam.
type PutEdge ¶
func PutEdgeParam ¶
type PutVertex ¶
PutVertex backs `put vertex <key> <value> [ttl_seconds] [type=…]`. Type is the optional value-type override migrated from `vertex put --value-type`: "" / "auto" auto-detects (int→float→bool→RFC3339→string); otherwise one of string|int|float|bool|datetime|duration|json.
func PutVertexParam ¶
type ScanEdges ¶ added in v0.9.0
ScanEdges backs `scan edges <tail-prefix> [limit] [head=<prefix>] [all=true]`. HeadPrefix narrows the head dimension as a server-side index lookup; All iterates every page.
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 backs `scan vertices <prefix> [limit] [all=true]` (#411, extended in #679). Limit is optional (0 = server default); All iterates every page and renders the full result.
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-cli 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.