justfile

package
v3.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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 Alias

type Alias struct {
	Name       string
	Target     string
	Attributes []*Attribute
	Pos        Position
}

type Assignment

type Assignment struct {
	Name       string
	Value      Expression
	Export     bool
	Eager      bool
	Private    bool
	Parameters []string // non-empty for function definitions: name(params) := expr
	Pos        Position
}

type Attribute

type Attribute struct {
	Name      string
	Arguments []AttributeArg
	Pos       Position
}

type AttributeArg

type AttributeArg struct {
	Key   string // empty for positional args
	Value string
}

type BacktickExpr

type BacktickExpr struct {
	Command  string
	Indented bool
	Pos      Position
}

func (*BacktickExpr) GetPos

func (b *BacktickExpr) GetPos() Position

type Comment

type Comment struct {
	Value string
	Pos   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

type Diagnostic struct {
	Pos      Position
	Severity Severity
	Message  string
	File     string
}

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 Import

type Import struct {
	Path     string
	Optional bool
	Justfile *Justfile // resolved by ParseFile, nil from Parse
	Pos      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

func Parse(content []byte) (*Justfile, error)

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

func ParseFile(filename string) (*Justfile, error)

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
}

func (*LogicalOp) GetPos

func (l *LogicalOp) GetPos() Position

type Module

type Module struct {
	Name       string
	Path       string // explicit path, empty if auto-discovered
	Optional   bool
	Justfile   *Justfile // resolved by ParseFile, nil from Parse
	Attributes []*Attribute
	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
}

func (*ParenExpr) GetPos

func (p *ParenExpr) GetPos() 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
}

func (*PathJoin) GetPos

func (p *PathJoin) GetPos() Position

type Position

type Position struct {
	Line   int
	Column int
	Offset int
}

func (Position) String

func (p Position) String() string

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 RecipeLine struct {
	Fragments   []Fragment
	Quiet       bool   // @
	NoError     bool   // -
	PrefixOrder string // "@-" or "-@" when both Quiet and NoError; empty otherwise
	Pos         Position
}

type Setting

type Setting struct {
	Name  string
	Value SettingValue
	Pos   Position
}

type SettingValue

type SettingValue struct {
	Bool   *bool
	String *string
	List   []string
}

func (SettingValue) Kind

func (sv SettingValue) Kind() string

Kind returns which type of value this setting holds: "bool", "string", "list", or "" if unset.

type Severity

type Severity int
const (
	SeverityError Severity = iota
	SeverityWarning
)

func (Severity) String

func (s Severity) String() string

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

type TextFragment struct {
	Value string
	Pos   Position
}

func (*TextFragment) GetPos

func (t *TextFragment) GetPos() Position

type Unexport

type Unexport struct {
	Name string
	Pos  Position
}

type Variable

type Variable struct {
	Name string
	Pos  Position
}

func (*Variable) GetPos

func (v *Variable) GetPos() Position

Jump to

Keyboard shortcuts

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