render

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Newline = "\n"

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorizedOutput added in v0.3.0

type ColorizedOutput struct{}

func (ColorizedOutput) Assignment added in v0.3.0

func (ColorizedOutput) Assignment(assignment *ast.Assignment, settings Settings) *Lines

func (ColorizedOutput) Comment added in v0.3.0

func (ColorizedOutput) Comment(comment *ast.Comment, settings Settings) *Lines

func (ColorizedOutput) GroupBanner added in v0.3.0

func (ColorizedOutput) GroupBanner(group *ast.Group, settings Settings) *Lines

func (ColorizedOutput) Newline added in v0.3.0

func (ColorizedOutput) Newline(newline *ast.Newline, settings Settings) *Lines

type Handler

type Handler func(hi *HandlerInput) HandlerSignal

type HandlerInput

type HandlerInput struct {
	CurrentStatement  any
	PreviousStatement ast.Statement
	Renderer          *Renderer
	ReturnValue       *Lines
	Settings          Settings
}

func (*HandlerInput) Continue

func (hi *HandlerInput) Continue() HandlerSignal

func (*HandlerInput) Return

func (hi *HandlerInput) Return(value *Lines) HandlerSignal

func (*HandlerInput) Stop

func (hi *HandlerInput) Stop() HandlerSignal

type HandlerSignal added in v0.3.0

type HandlerSignal uint
const (
	Continue HandlerSignal = iota
	Stop
	Return
)

func FilterComments added in v0.3.0

func FilterComments(hi *HandlerInput) HandlerSignal

FilterComments will filter out Comment statements if they aren't to be included

func FilterDisabledStatements added in v0.3.0

func FilterDisabledStatements(hi *HandlerInput) HandlerSignal

FilterDisabledStatements will filter out Assignment Statements that are disabled

func FilterGroupName added in v0.3.0

func FilterGroupName(hi *HandlerInput) HandlerSignal

FilterGroupName will filter out Statements that do not belong to the required Group name

func FilterKeyPrefix added in v0.3.0

func FilterKeyPrefix(hi *HandlerInput) HandlerSignal

FilterKeyPrefix will filter out Assignment Statements that do not have the configured (optional) key prefix.

func FormatterHandler added in v0.3.0

func FormatterHandler(hi *HandlerInput) HandlerSignal

FormatterHandler is responsible for formatting an .env file according to our opinionated style.

func (HandlerSignal) String added in v0.3.0

func (hs HandlerSignal) String() string

String returns the string corresponding to the Handler Signal.

type Line added in v0.3.0

type Line struct {
	Literal string // The *real* value of the line being added
	Debug   string // A debug value to help track where NewLines are coming from (use DEBUG=1 to see them when using --pretty)
}

Line represents a line in an output

func (Line) String added in v0.3.0

func (l Line) String() string

type Lines added in v0.3.0

type Lines struct {
	// contains filtered or unexported fields
}

Lines is a collection of lines

func NewLinesCollection added in v0.3.0

func NewLinesCollection() *Lines

func (*Lines) Add added in v0.3.0

func (lb *Lines) Add(value string) *Lines

Add a new arbitrary string to the Lines instance

func (*Lines) Append added in v0.3.0

func (lb *Lines) Append(buf *Lines) *Lines

Append adds one Lines collection to the end of another if its's not empty

func (*Lines) IsEmpty added in v0.3.0

func (lb *Lines) IsEmpty() bool

IsEmpty returns if the Line has any lines or not

func (*Lines) Newline added in v0.3.0

func (lb *Lines) Newline(id ...string) *Lines

Newline adds a Newline to the collection

Optionally accepts a list of strings to help identify what the "origin" or reason for the newline is.

This can be seen when using [DEBUG=1] environment variable along with [--pretty] CLI flag

func (Lines) String added in v0.3.0

func (lb Lines) String() string

String joins all the LineItems together into slice and Join them by a newline + an additional trailing newline.

type Output added in v0.3.0

type Output interface {
	GroupBanner(*ast.Group, Settings) *Lines
	Assignment(*ast.Assignment, Settings) *Lines
	Comment(*ast.Comment, Settings) *Lines
	Newline(*ast.Newline, Settings) *Lines
}

type PlainOutput added in v0.3.0

type PlainOutput struct{}

func (PlainOutput) Assignment added in v0.3.0

func (PlainOutput) Assignment(a *ast.Assignment, settings Settings) *Lines

func (PlainOutput) Comment added in v0.3.0

func (r PlainOutput) Comment(comment *ast.Comment, settings Settings) *Lines

func (PlainOutput) GroupBanner added in v0.3.0

func (PlainOutput) GroupBanner(group *ast.Group, settings Settings) *Lines

func (PlainOutput) Newline added in v0.3.0

func (r PlainOutput) Newline(newline *ast.Newline, settings Settings) *Lines

type Renderer

type Renderer struct {
	Output            Output
	PreviousStatement ast.Statement
	Settings          Settings
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter() *Renderer

func NewRenderer

func NewRenderer(settings Settings, additionalHandlers ...Handler) *Renderer

func (*Renderer) Statement

func (r *Renderer) Statement(currentStatement any) *Lines

Statement is the main loop of the Renderer.

It's responsible for delegating statements to handlers, calling the right Output functions and track the ordering of Statements being rendered

type Settings

type Settings struct {
	ShowGroupBanners bool
	// contains filtered or unexported fields
}

func NewSettings added in v0.3.0

func NewSettings(options ...SettingsOption) *Settings

func (*Settings) Apply added in v0.3.0

func (s *Settings) Apply(options ...SettingsOption) *Settings

func (Settings) ShowBlankLines

func (rs Settings) ShowBlankLines() bool

type SettingsOption added in v0.3.0

type SettingsOption func(*Settings)

func WithBlankLines added in v0.3.0

func WithBlankLines(b bool) SettingsOption

func WithColors added in v0.3.0

func WithColors(b bool) SettingsOption

func WithComments added in v0.3.0

func WithComments(b bool) SettingsOption

func WithFilterGroup added in v0.3.0

func WithFilterGroup(name string) SettingsOption

func WithFilterKeyPrefix added in v0.3.0

func WithFilterKeyPrefix(prefix string) SettingsOption

func WithFormattedOutput added in v0.3.0

func WithFormattedOutput(b bool) SettingsOption

func WithGroupBanners added in v0.3.0

func WithGroupBanners(b bool) SettingsOption

func WithIncludeDisabled added in v0.3.0

func WithIncludeDisabled(b bool) SettingsOption

func WithInterpolation added in v0.3.0

func WithInterpolation(b bool) SettingsOption

Jump to

Keyboard shortcuts

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