render

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 7 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(ctx context.Context, assignment *ast.Assignment, settings Settings) *Lines

func (ColorizedOutput) Comment added in v0.3.0

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

func (ColorizedOutput) GroupBanner added in v0.3.0

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

func (ColorizedOutput) Newline added in v0.3.0

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

type CompletionOutputKeys added in v0.6.1

type CompletionOutputKeys struct{}

func (CompletionOutputKeys) Assignment added in v0.6.1

func (CompletionOutputKeys) Assignment(ctx context.Context, assignment *ast.Assignment, settings Settings) *Lines

func (CompletionOutputKeys) Comment added in v0.6.1

func (r CompletionOutputKeys) Comment(ctx context.Context, comment *ast.Comment, settings Settings) *Lines

func (CompletionOutputKeys) GroupBanner added in v0.6.1

func (CompletionOutputKeys) GroupBanner(ctx context.Context, group *ast.Group, settings Settings) *Lines

func (CompletionOutputKeys) Newline added in v0.6.1

func (r CompletionOutputKeys) Newline(ctx context.Context, newline *ast.Newline, settings Settings) *Lines

type Handler

type Handler func(ctx context.Context, hi *HandlerInput) HandlerSignal

func NewAstSelectorHandler added in v0.9.0

func NewAstSelectorHandler(selectors ...ast.Selector) Handler

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 FormatterHandler added in v0.3.0

func FormatterHandler(ctx context.Context, input *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) Lines added in v0.6.1

func (lb Lines) Lines() []string

Lines returns the raw slice of lines

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(ctx context.Context, group *ast.Group, settings Settings) *Lines
	Assignment(ctx context.Context, assignment *ast.Assignment, settings Settings) *Lines
	Comment(ctx context.Context, comment *ast.Comment, settings Settings) *Lines
	Newline(ctx context.Context, newline *ast.Newline, settings Settings) *Lines
}

type OutputType added in v0.6.1

type OutputType uint
const (
	Plain OutputType = iota
	Colorized
	CompletionKeyOnly
)

type PlainOutput added in v0.3.0

type PlainOutput struct{}

func (PlainOutput) Assignment added in v0.3.0

func (PlainOutput) Assignment(ctx context.Context, assignment *ast.Assignment, settings Settings) *Lines

func (PlainOutput) Comment added in v0.3.0

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

func (PlainOutput) GroupBanner added in v0.3.0

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

func (PlainOutput) Newline added in v0.3.0

func (r PlainOutput) Newline(ctx context.Context, 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, extraHandlers ...Handler) *Renderer

func NewUnfilteredRenderer added in v0.6.1

func NewUnfilteredRenderer(settings *Settings, extraHandlers ...Handler) *Renderer

func (*Renderer) Statement

func (r *Renderer) Statement(ctx context.Context, 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

	InterpolatedValues 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) Handlers added in v0.6.2

func (rs Settings) Handlers() []ast.Selector

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(boolean 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

func WithOutputType added in v0.6.1

func WithOutputType(t OutputType) SettingsOption

func WithOutputter added in v0.6.1

func WithOutputter(o Output) SettingsOption

Jump to

Keyboard shortcuts

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