Documentation
¶
Overview ¶
Package lastquery provides persistence and retrieval of the most recent query results. This enables numbered references to query results for selective operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoLastQuery = errors.New("no last query available") ErrInvalidNumber = errors.New("invalid result number") ErrNumberOutOfRange = errors.New("result number out of range") )
Errors
Functions ¶
func ParseNumberArgs ¶
ParseNumberArgs parses multiple string arguments as numbers. Joins args with commas and delegates to ParseNumbers. This allows: "1" "3" "5" to be parsed as [1, 3, 5]
func ParseNumbers ¶
ParseNumbers parses a string of result numbers into a slice of ints. Supports multiple formats:
- Single number: "1"
- Comma-separated: "1,3,5"
- Range: "1-5"
- Mixed: "1,3-5,7"
- Space-separated (multiple args): handled by caller joining with commas
Returns 1-indexed numbers as provided by user.
Types ¶
type LastQuery ¶
type LastQuery struct {
Query string `json:"query"`
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"` // "trait" or "object"
Results []ResultEntry `json:"results"`
}
LastQuery stores the results of the most recent query. Persisted to .raven/last-query.json for use in follow-up commands.
func Read ¶
Read loads the last query results from disk. Returns ErrNoLastQuery if no last query file exists.
func (*LastQuery) GetByNumbers ¶
func (lq *LastQuery) GetByNumbers(nums []int) ([]ResultEntry, error)
GetByNumbers returns the entries matching the given numbers. Numbers are 1-indexed (as displayed to users). Returns an error if any number is out of range.
type ResultEntry ¶
type ResultEntry struct {
Num int `json:"num"` // 1-indexed number for user reference
ID string `json:"id"` // Unique identifier (trait ID or object ID)
Kind string `json:"kind"` // "trait", "object", "reference", or "search"
Content string `json:"content"` // Human-readable description
Location string `json:"location"` // Short location (e.g., "daily/2026-01-25:42")
FilePath string `json:"file_path"` // Full file path
Line int `json:"line"` // Line number
// Trait-specific fields (nil/empty for non-traits)
TraitType string `json:"trait_type,omitempty"`
TraitValue *string `json:"trait_value,omitempty"`
// Object-specific fields (nil/empty for non-objects)
ObjectType string `json:"object_type,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
}
ResultEntry represents a single result from the query. Contains all data needed for display and operations.