Documentation
¶
Overview ¶
Package justfile parses and validates justfiles.
Use Parse to parse justfile content from bytes, or ParseFile to parse from disk with automatic import and module resolution. Call Justfile.Validate to run semantic analysis and get diagnostics.
Index ¶
- Constants
- type Alias
- type Assignment
- type Attribute
- type AttributeArg
- type BacktickExpr
- type Comment
- type Comparison
- type Concatenation
- type Conditional
- type Dependency
- type Diagnostic
- type Expression
- type Fragment
- type FunctionCall
- type Import
- type InterpolationFragment
- type Justfile
- type LogicalOp
- type Module
- type Parameter
- type ParenExpr
- type ParseError
- type PathJoin
- type Position
- type Recipe
- type RecipeLine
- type Setting
- type SettingValue
- type Severity
- type StringLiteral
- type TextFragment
- type Unexport
- type Variable
Constants ¶
const ( StringKindQuoted = "string" StringKindRaw = "raw string" StringKindIndentedQuoted = "indented string" StringKindIndentedRaw = "indented raw string" StringKindBacktick = "backtick" StringKindIndentedBacktick = "indented backtick" StringKindShellExpanded = "shell-expanded string" StringKindShellExpandedRaw = "shell-expanded raw string" StringKindFormat = "format string" )
StringKind identifies the type of string literal in the source.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assignment ¶
type Attribute ¶
type Attribute struct {
Name string
Arguments []AttributeArg
Pos Position
}
type AttributeArg ¶
type BacktickExpr ¶
func (*BacktickExpr) GetPos ¶
func (b *BacktickExpr) GetPos() Position
type Comparison ¶
type Comparison struct {
Left Expression
Right Expression
Operator string // "==", "!=", "=~", "!~"
Pos Position
}
func (*Comparison) GetPos ¶
func (c *Comparison) GetPos() Position
type Concatenation ¶
type Concatenation struct {
Left Expression
Right Expression
Pos Position
}
func (*Concatenation) GetPos ¶
func (c *Concatenation) GetPos() Position
type Conditional ¶
type Conditional struct {
Condition Comparison
Then Expression
Otherwise Expression
Pos Position
}
func (*Conditional) GetPos ¶
func (c *Conditional) GetPos() Position
type Dependency ¶
type Dependency struct {
Name string
Arguments []Expression
Subsequent bool // after &&
Pos Position
}
type Diagnostic ¶
func (Diagnostic) String ¶
func (d Diagnostic) String() string
type Expression ¶
type Expression interface {
GetPos() Position
// contains filtered or unexported methods
}
Expression represents any expression in a justfile.
type Fragment ¶
type Fragment interface {
GetPos() Position
// contains filtered or unexported methods
}
Fragment is a piece of a recipe line — either text or an interpolation.
type FunctionCall ¶
type FunctionCall struct {
Name string
Arguments []Expression
Pos Position
}
func (*FunctionCall) GetPos ¶
func (f *FunctionCall) GetPos() Position
type InterpolationFragment ¶
type InterpolationFragment struct {
Expression Expression
Pos Position
}
func (*InterpolationFragment) GetPos ¶
func (i *InterpolationFragment) GetPos() Position
type Justfile ¶
type Justfile struct {
Recipes []*Recipe
Assignments []*Assignment
Unexports []*Unexport
Aliases []*Alias
Settings []*Setting
Imports []*Import
Modules []*Module
Comments []*Comment
File string // source filename, empty for Parse()
}
Justfile is the root AST node representing a parsed justfile.
func Parse ¶
Parse parses justfile content from bytes. Import and module statements are represented as AST nodes but not resolved — use ParseFile to automatically resolve imports and modules from disk.
func ParseFile ¶
ParseFile reads and parses a justfile from disk. Imports and modules are resolved recursively relative to the file's directory.
Security note: ParseFile follows import and module paths specified in the justfile, which may reference files outside the justfile's directory (including absolute paths and ~/). Do not use ParseFile on untrusted justfiles if file read side effects are a concern. Use Parse instead to parse without filesystem access.
func (*Justfile) Validate ¶
func (jf *Justfile) Validate() []Diagnostic
Validate performs semantic analysis on a parsed justfile and returns any diagnostics found. It checks for duplicate definitions, undefined references, and invalid configurations.
type LogicalOp ¶
type LogicalOp struct {
Left Expression
Right Expression
Operator string // "&&", "||"
Pos Position
}
type Parameter ¶
type Parameter struct {
Name string
Default Expression // nil if no default
Export bool // prefixed with $
Variadic string // "", "*", or "+"
Pos Position
}
type ParenExpr ¶
type ParenExpr struct {
Inner Expression
Pos Position
}
type ParseError ¶
type ParseError struct {
Pos Position
Message string
File string
Err error // underlying error, if any
}
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type PathJoin ¶
type PathJoin struct {
Left Expression
Right Expression
Pos Position
}
type Recipe ¶
type Recipe struct {
Name string
Parameters []*Parameter
Dependencies []*Dependency
Body []*RecipeLine
Attributes []*Attribute
Shebang string // e.g. "#!/usr/bin/env bash", empty if none
Quiet bool // prefixed with @
Comment string
Pos Position
}
type RecipeLine ¶
type Setting ¶
type Setting struct {
Name string
Value SettingValue
Pos Position
}
type SettingValue ¶
func (SettingValue) Kind ¶
func (sv SettingValue) Kind() string
Kind returns which type of value this setting holds: "bool", "string", "list", or "" if unset.
type StringLiteral ¶
type StringLiteral struct {
Value string
Kind string // StringKind* constant identifying the string type
Pos Position
}
func (*StringLiteral) GetPos ¶
func (s *StringLiteral) GetPos() Position
type TextFragment ¶
func (*TextFragment) GetPos ¶
func (t *TextFragment) GetPos() Position