Documentation
¶
Overview ¶
Package ast declares the types used to represent syntax trees for the .env file.
Index ¶
- type Assignment
- func (a *Assignment) BelongsToGroup(name string) bool
- func (a *Assignment) CommentsSlice() []string
- func (a *Assignment) Disable()
- func (a *Assignment) Documentation(withoutPrefix bool) string
- func (a *Assignment) DocumentationSummary() string
- func (a *Assignment) Enable()
- func (a *Assignment) HasComments() bool
- func (a *Assignment) Is(other Statement) bool
- func (a *Assignment) IsHidden() bool
- func (a *Assignment) Type() string
- func (a *Assignment) ValidationRules() string
- type Comment
- type Document
- func (d *Document) AllAssignments() []*Assignment
- func (d *Document) Assignments() []*Assignment
- func (d *Document) BelongsToGroup(name string) bool
- func (doc *Document) EnsureGroup(name string) *Group
- func (d *Document) Get(name string) *Assignment
- func (d *Document) GetAssignmentIndex(name string) (int, *Assignment)
- func (d *Document) GetConfig(name string) (string, error)
- func (d *Document) GetGroup(name string) *Group
- func (d *Document) Has(name string) bool
- func (d *Document) HasGroup(name string) bool
- func (doc *Document) Interpolate(target *Assignment) (string, error)
- func (d *Document) Is(other Statement) bool
- func (d *Document) Type() string
- func (doc *Document) Upsert(input *Assignment, options UpsertOptions) (*Assignment, error)
- type Group
- type Newline
- type Position
- type Selector
- type SelectorResult
- type Statement
- type StatementCollection
- type UpsertOptions
- type UpsertPlacement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assignment ¶
type Assignment struct { Name string `json:"key"` // Name of the key (left hand side of the "=" sign) Literal string `json:"literal"` // Value of the key (right hand side of the "=" sign) Interpolated string `json:"value"` // Value of the key (after interpolation) Complete bool `json:"complete"` // The key/value had no value/content after the "=" sign Active bool `json:"commented"` // The assignment was commented out (#KEY=VALUE) Quote token.Quote `json:"quote"` // The style of quotes used for the assignment Group *Group `json:"-"` // The (optional) group this assignment belongs to Comments []*Comment `json:"comments"` // Comments attached to the assignment (e.g. doc block before it) Position Position `json:"position"` // Information about position of the assignment in the file }
func (*Assignment) BelongsToGroup ¶
func (a *Assignment) BelongsToGroup(name string) bool
func (*Assignment) CommentsSlice ¶ added in v0.7.0
func (a *Assignment) CommentsSlice() []string
func (*Assignment) Disable ¶ added in v0.6.0
func (a *Assignment) Disable()
func (*Assignment) Documentation ¶ added in v0.2.0
func (a *Assignment) Documentation(withoutPrefix bool) string
func (*Assignment) DocumentationSummary ¶ added in v0.6.2
func (a *Assignment) DocumentationSummary() string
func (*Assignment) Enable ¶ added in v0.6.0
func (a *Assignment) Enable()
func (*Assignment) HasComments ¶
func (a *Assignment) HasComments() bool
func (*Assignment) Is ¶
func (a *Assignment) Is(other Statement) bool
func (*Assignment) IsHidden ¶ added in v0.6.2
func (a *Assignment) IsHidden() bool
func (*Assignment) Type ¶ added in v0.3.0
func (a *Assignment) Type() string
func (*Assignment) ValidationRules ¶
func (a *Assignment) ValidationRules() string
type Comment ¶
type Comment struct { Value string `json:"value"` // The actual comment value Annotation *token.Annotation `json:"annotation"` // If the comment was detected to be an annotation Group *Group `json:"-"` // The (optional) group the comment belongs to Position Position `json:"position"` // Information about position of the assignment in the file }
Comment node represents a comment statement.
func NewComment ¶
func (*Comment) BelongsToGroup ¶
func (Comment) CleanString ¶ added in v0.7.0
type Document ¶
type Document struct { Statements []Statement `json:"statements"` // Statements belonging to the root of the document Groups []*Group `json:"groups"` // Groups within the document Annotations []*Comment `json:"-"` // Global annotations for configuration of dottie }
Document node represents .env file statement, that contains assignments and comments.
func (*Document) AllAssignments ¶ added in v0.7.0
func (d *Document) AllAssignments() []*Assignment
func (*Document) Assignments ¶
func (d *Document) Assignments() []*Assignment
func (*Document) BelongsToGroup ¶
func (*Document) EnsureGroup ¶ added in v0.1.0
func (*Document) Get ¶
func (d *Document) Get(name string) *Assignment
func (*Document) GetAssignmentIndex ¶ added in v0.7.0
func (d *Document) GetAssignmentIndex(name string) (int, *Assignment)
func (*Document) Interpolate ¶ added in v0.4.0
func (doc *Document) Interpolate(target *Assignment) (string, error)
func (*Document) Upsert ¶ added in v0.4.0
func (doc *Document) Upsert(input *Assignment, options UpsertOptions) (*Assignment, error)
type Group ¶
type Group struct { Name string `json:"name"` // Name of the group (within the header) Statements []Statement `json:"statements"` // Statements within the group Position Position `json:"position"` // Positional information about the group }
func (*Group) Assignments ¶ added in v0.7.0
func (g *Group) Assignments() []*Assignment
func (*Group) BelongsToGroup ¶
func (*Group) GetAssignmentIndex ¶ added in v0.7.0
func (g *Group) GetAssignmentIndex(name string) (int, *Assignment)
type Newline ¶
type Position ¶
type Selector ¶ added in v0.6.2
type Selector func(input Statement) SelectorResult
func ExcludeKeyPrefix ¶ added in v0.6.2
ExcludeKeyPrefix will *EXCLUDE* Assignments with the provided prefix
func RetainExactKey ¶ added in v0.6.9
RetainExactKey will *RETAIN* Assignments with the exact name
func RetainGroup ¶ added in v0.6.2
RetainGroup will exclude Assignment, Group, and Comment statements that do not belong to the provided group name
func RetainKeyPrefix ¶ added in v0.6.2
RetainKeyPrefix will *RETAIN* Assignments with the provided prefix
type SelectorResult ¶ added in v0.6.2
type SelectorResult uint
const ( Exclude SelectorResult = iota Keep )
func ExcludeActiveAssignments ¶ added in v0.6.2
func ExcludeActiveAssignments(input Statement) SelectorResult
ExcludeActiveAssignments will exclude *ACTIVE* Assignments
func ExcludeComments ¶ added in v0.6.2
func ExcludeComments(input Statement) SelectorResult
ExcludeComments will *EXCLUDE* all comments
func ExcludeDisabledAssignments ¶ added in v0.6.2
func ExcludeDisabledAssignments(input Statement) SelectorResult
ExcludeDisabledAssignments will exclude *DISABLED* Assignments
func ExcludeHiddenViaAnnotation ¶ added in v0.6.2
func ExcludeHiddenViaAnnotation(input Statement) SelectorResult
ExcludeHiddenViaAnnotation will exclude *HIDDEN* Assignments via the [@dottie/hidden] annotation
type Statement ¶
type Statement interface { Is(statement Statement) bool Type() string // contains filtered or unexported methods }
Statement represents syntax tree node of .env file statement (like: assignment or comment).
type StatementCollection ¶ added in v0.7.0
type StatementCollection interface { Assignments() []*Assignment GetAssignmentIndex(name string) (int, *Assignment) }
type UpsertOptions ¶ added in v0.4.0
type UpsertPlacement ¶ added in v0.7.0
type UpsertPlacement uint
const ( UpsertLast UpsertPlacement = iota UpsertAfter UpsertBefore UpsertFirst )