ast

package
v0.4.0-beta.30 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSpinnerName string = "Running..."

Variables

View Source
var KindConditionalEnd = goldast.NewNodeKind("ConditionalEnd")
View Source
var KindConditionalStart = goldast.NewNodeKind("ConditionalStart")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindDescriptionBlock = goldast.NewNodeKind("DescriptionBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindEnvironmentSubstitution = goldast.NewNodeKind("EnvironmentSubstitution")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindExecutionBlock = goldast.NewNodeKind("ExecutionBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindIgnoreBlock = goldast.NewNodeKind("IgnoreBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindImportBlock = goldast.NewNodeKind("ImportBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindInvisibleBlock = goldast.NewNodeKind("InvisibleBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindInvokeBlock = goldast.NewNodeKind("InvokeBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindOnFailure = goldast.NewNodeKind("OnFailure")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindRundownBlock = goldast.NewNodeKind("RundownBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSaveCodeBlock = goldast.NewNodeKind("SaveCodeBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSectionGroup = goldast.NewNodeKind("SectionGroup")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSectionOption = goldast.NewNodeKind("SectionOption")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSectionPointer = goldast.NewNodeKind("SectionPointer")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSkipBlock = goldast.NewNodeKind("SkipBlock")
View Source
var KindStopFail = goldast.NewNodeKind("StopFail")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindStopOk = goldast.NewNodeKind("StopOk")

KindRundownBlock is a NodeKind of the RundownBlock node.

View Source
var KindSubEnvBlock = goldast.NewNodeKind("SubEnvBlock")

KindRundownBlock is a NodeKind of the RundownBlock node.

Functions

func CopyChildren

func CopyChildren(from goldast.Node, to goldast.Node)

func CopyNode

func CopyNode(node goldast.Node) goldast.Node

func CopySettings

func CopySettings(from goldast.Node, to goldast.Node)

func DetermineSkipTarget

func DetermineSkipTarget(n *SkipBlock) goldast.Node

func FillInvokeBlocks

func FillInvokeBlocks(node goldast.Node, maxRecursion int) error

Iterates through each child of the given block, identifying InvokeBlocks and copying the invocation contents into the block.

func FindNode

func FindNode(parent gold_ast.Node, finder func(n gold_ast.Node) bool) gold_ast.Node

func FindNodeBackwards

func FindNodeBackwards(currentNode gold_ast.Node, finder func(n gold_ast.Node) bool) gold_ast.Node

Searches previous siblings, and then previous parent's siblings, and so on

func FindNodeBackwardsDeeply

func FindNodeBackwardsDeeply(currentNode gold_ast.Node, finder func(n gold_ast.Node) bool) gold_ast.Node

Searches backwards depth-first.

func PopulateSkipTargets

func PopulateSkipTargets(doc *goldast.Document)

Populates the next AST node for each of the Skip nodes.

func PruneActions

func PruneActions(doc goldast.Node)

func PruneDocumentToRoot

func PruneDocumentToRoot(doc goldast.Node)

func PruneDocumentToSection

func PruneDocumentToSection(doc goldast.Node, sectionName string) *goldast.Document

Reduces the document to just the requested section.

Types

type Conditional

type Conditional interface {
	HasIfScript() bool
	GetIfScript() string
	SetIfScript(string)
	GetResult() bool
	SetResult(bool)
	HasResult() bool
}

type ConditionalEnd

type ConditionalEnd struct {
	goldast.BaseBlock
	Start *ConditionalStart
}

func (*ConditionalEnd) Dump

func (n *ConditionalEnd) Dump(source []byte, level int)

func (*ConditionalEnd) Kind

func (n *ConditionalEnd) Kind() goldast.NodeKind

Kind implements Node.Kind.

type ConditionalImpl

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

func (*ConditionalImpl) GetIfScript

func (n *ConditionalImpl) GetIfScript() string

func (*ConditionalImpl) GetResult

func (n *ConditionalImpl) GetResult() bool

func (*ConditionalImpl) HasIfScript

func (n *ConditionalImpl) HasIfScript() bool

func (*ConditionalImpl) HasResult

func (n *ConditionalImpl) HasResult() bool

func (*ConditionalImpl) SetIfScript

func (n *ConditionalImpl) SetIfScript(script string)

func (*ConditionalImpl) SetResult

func (n *ConditionalImpl) SetResult(result bool)

type ConditionalStart

type ConditionalStart struct {
	goldast.BaseBlock
	ConditionalImpl
	ID  string
	End *ConditionalEnd
}

func NewConditionalStart

func NewConditionalStart() *ConditionalStart

NewRundownBlock returns a new RundownBlock node.

func (*ConditionalStart) Dump

func (n *ConditionalStart) Dump(source []byte, level int)

func (*ConditionalStart) GetEndSkipNode

func (n *ConditionalStart) GetEndSkipNode(goldast.Node) goldast.Node

func (*ConditionalStart) Kind

func (n *ConditionalStart) Kind() goldast.NodeKind

Kind implements Node.Kind.

type DescriptionBlock

type DescriptionBlock struct {
	goldast.BaseBlock
}

func GetRootHelp

func GetRootHelp(doc goldast.Node) *DescriptionBlock

Walks through the top-level nodes in the AST under document. Will return the first help node before the sections begin.

func NewDescriptionBlock

func NewDescriptionBlock() *DescriptionBlock

NewRundownBlock returns a new RundownBlock node.

func (*DescriptionBlock) Dump

func (n *DescriptionBlock) Dump(source []byte, level int)

func (*DescriptionBlock) Kind

func (n *DescriptionBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type EnvironmentSubstitution

type EnvironmentSubstitution struct {
	goldast.String
}

func NewSubEnvInline

func NewSubEnvInline(contents string) *EnvironmentSubstitution

NewRundownBlock returns a new RundownBlock node.

func (*EnvironmentSubstitution) Dump

func (n *EnvironmentSubstitution) Dump(source []byte, level int)

func (*EnvironmentSubstitution) Kind

Kind implements Node.Kind.

type ExecutionBlock

type ExecutionBlock struct {
	goldast.BaseBlock
	ConditionalImpl

	CodeBlock *goldast.FencedCodeBlock

	ID                    string
	ShowStdout            bool
	ShowStderr            bool
	CaptureStdoutInto     string
	Reveal                bool
	Execute               bool
	CaptureEnvironment    []string
	SubstituteEnvironment bool
	SpinnerName           string
	SpinnerMode           SpinnerMode
	With                  string
	Language              string
	ReplaceProcess        bool
	SkipOnSuccess         bool
	SkipOnFailure         bool
}

func NewExecutionBlock

func NewExecutionBlock(fcb *goldast.FencedCodeBlock) *ExecutionBlock

NewRundownBlock returns a new RundownBlock node.

func (*ExecutionBlock) Dump

func (n *ExecutionBlock) Dump(source []byte, level int)

func (*ExecutionBlock) Kind

func (n *ExecutionBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type FarSkip

type FarSkip interface {
	GetEndSkipNode(gold_ast.Node) gold_ast.Node
}

type IgnoreBlock

type IgnoreBlock struct {
	goldast.BaseBlock
}

func NewIgnoreBlock

func NewIgnoreBlock() *IgnoreBlock

NewRundownBlock returns a new RundownBlock node.

func (*IgnoreBlock) Dump

func (n *IgnoreBlock) Dump(source []byte, level int)

func (*IgnoreBlock) Kind

func (n *IgnoreBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type ImportBlock

type ImportBlock struct {
	goldast.BaseBlock

	ImportPrefix string
}

The rundown import block expects to wrap a markdown link to the file to import.

For example: <r import="ci">[Our CI scripts](./ci/RUNDOWN.md)</r>

Will import our the ./ci/RUNDOWN.md file, namespacing all commands under the "ci:" prefix.

func NewImportBlock

func NewImportBlock() *ImportBlock

NewImportBlock returns a new RundownBlock node.

func ProcessImportBlocks

func ProcessImportBlocks(doc goldast.Node) []*ImportBlock

func (*ImportBlock) Dump

func (n *ImportBlock) Dump(source []byte, level int)

func (*ImportBlock) GetFilename

func (n *ImportBlock) GetFilename() string

func (*ImportBlock) IngestChildren

func (n *ImportBlock) IngestChildren(doc goldast.Node)

func (*ImportBlock) Kind

func (n *ImportBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type InvisibleBlock

type InvisibleBlock struct {
	goldast.BaseBlock

	ImportPrefix string
}

func NewInvisibleBlock

func NewInvisibleBlock() *InvisibleBlock

NewRundownBlock returns a new RundownBlock node.

func (*InvisibleBlock) Dump

func (n *InvisibleBlock) Dump(source []byte, level int)

func (*InvisibleBlock) Kind

func (n *InvisibleBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type InvokeBlock

type InvokeBlock struct {
	goldast.BaseBlock

	Invoke       string
	AsDependency bool
	Args         map[string]string

	PreviousEnv map[string]string

	Target *SectionPointer
}

func NewInvokeBlock

func NewInvokeBlock() *InvokeBlock

NewRundownBlock returns a new RundownBlock node.

func (*InvokeBlock) Dump

func (n *InvokeBlock) Dump(source []byte, level int)

func (*InvokeBlock) Kind

func (n *InvokeBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type OnFailure

type OnFailure struct {
	goldast.BaseBlock
	FailureMessageRegexp string
}

func GetOnFailureNodes

func GetOnFailureNodes(node goldast.Node) []*OnFailure

Searches the current node's section for OnFailure nodes and returns them.

func NewOnFailure

func NewOnFailure() *OnFailure

NewRundownBlock returns a new RundownBlock node.

func (*OnFailure) ConvertToParagraph

func (n *OnFailure) ConvertToParagraph() *goldast.Paragraph

func (*OnFailure) Dump

func (n *OnFailure) Dump(source []byte, level int)

func (*OnFailure) Kind

func (n *OnFailure) Kind() goldast.NodeKind

Kind implements Node.Kind.

func (*OnFailure) MatchesError

func (n *OnFailure) MatchesError(output []byte) bool

type OptionType

type OptionType interface {
	Validate(input string) error       // Validates the normalised input
	Normalise(input string) string     // Treats the input into a standard format
	ResolvedValue(input string) string // Converts input into it's final value to be set into the context
	Describe() string                  // Describes the input and what it accepts
	InputType() string                 // Human relatable input type (string, int, boolean, etc)
}

func BuildOptionType

func BuildOptionType(optionType string) (OptionType, error)

type OptionTypeRuntime

type OptionTypeRuntime interface {
	NormaliseToPath(input string, path string) (string, error)
}

type RundownBlock

type RundownBlock struct {
	goldast.BaseBlock
	TagName string
	Attrs   []html.Attribute
}

func NewRundownBlock

func NewRundownBlock() *RundownBlock

NewRundownBlock returns a new RundownBlock node.

func (*RundownBlock) Dump

func (n *RundownBlock) Dump(source []byte, level int)

Dump implements Node.Dump.

func (*RundownBlock) GetAttr

func (r *RundownBlock) GetAttr(name string) null.String

func (*RundownBlock) GetAttrList

func (r *RundownBlock) GetAttrList(name string) []string

func (*RundownBlock) GetFirstAttr

func (r *RundownBlock) GetFirstAttr(names ...string) null.String

func (*RundownBlock) HasAttr

func (r *RundownBlock) HasAttr(names ...string) bool

func (*RundownBlock) Kind

func (n *RundownBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type SaveCodeBlock

type SaveCodeBlock struct {
	goldast.BaseBlock
	CodeBlock *goldast.FencedCodeBlock

	Reveal         bool
	SaveToVariable string
	Replacements   map[string]string
}

func NewSaveCodeBlock

func NewSaveCodeBlock(fcb *goldast.FencedCodeBlock, saveToVariable string) *SaveCodeBlock

NewRundownBlock returns a new RundownBlock node.

func (*SaveCodeBlock) Dump

func (n *SaveCodeBlock) Dump(source []byte, level int)

func (*SaveCodeBlock) Kind

func (n *SaveCodeBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type SectionGroup

type SectionGroup struct {
	goldast.BaseBlock

	Name             string
	DescriptionShort string
	DescriptionLong  *DescriptionBlock
}

func NewSectionGroup

func NewSectionGroup(name string) *SectionGroup

NewRundownBlock returns a new RundownBlock node.

func (*SectionGroup) Dump

func (n *SectionGroup) Dump(source []byte, level int)

func (*SectionGroup) Kind

func (n *SectionGroup) Kind() goldast.NodeKind

Kind implements Node.Kind.

type SectionOption

type SectionOption struct {
	goldast.BaseInline
	OptionName        string
	OptionType        OptionType
	OptionTypeString  string
	OptionDescription string
	OptionPrompt      null.String
	OptionDefault     null.String
	OptionRequired    bool
	OptionAs          string
}

func NewSectionOption

func NewSectionOption(name string) *SectionOption

NewRundownBlock returns a new RundownBlock node.

func (*SectionOption) Dump

func (n *SectionOption) Dump(source []byte, level int)

func (*SectionOption) Kind

func (n *SectionOption) Kind() goldast.NodeKind

Kind implements Node.Kind.

type SectionPointer

type SectionPointer struct {
	goldast.BaseBlock
	ConditionalImpl

	SectionName      string
	StartNode        goldast.Node
	Options          []*SectionOption
	DescriptionShort string
	DescriptionLong  *DescriptionBlock
	Silent           bool

	ParentSection *SectionPointer

	Dependencies []*SectionPointer
}

func FindParentSection

func FindParentSection(heading goldast.Node) *SectionPointer

func FindSectionInDocument

func FindSectionInDocument(parent goldast.Node, name string) *SectionPointer

func GetNextSection

func GetNextSection(section *SectionPointer) *SectionPointer

Returns the next section in the AST for this Node.

func GetSectionForNode

func GetSectionForNode(node goldast.Node) *SectionPointer

Locates the section this node is in.

func GetSections

func GetSections(doc goldast.Node) []*SectionPointer

func NewSectionPointer

func NewSectionPointer(name string) *SectionPointer

NewRundownBlock returns a new RundownBlock node.

func (*SectionPointer) AddOption

func (n *SectionPointer) AddOption(option *SectionOption)

func (*SectionPointer) Dump

func (n *SectionPointer) Dump(source []byte, level int)

func (*SectionPointer) FirstContentNode

func (n *SectionPointer) FirstContentNode() goldast.Node

func (*SectionPointer) GetOption

func (n *SectionPointer) GetOption(name string) *SectionOption

func (*SectionPointer) GetOptionByEnvName

func (n *SectionPointer) GetOptionByEnvName(name string) *SectionOption

func (*SectionPointer) Kind

func (n *SectionPointer) Kind() goldast.NodeKind

Kind implements Node.Kind.

func (*SectionPointer) ParseOptions

func (n *SectionPointer) ParseOptions(options map[string]string) (map[string]string, error)

func (*SectionPointer) ParseOptionsWithResolution

func (n *SectionPointer) ParseOptionsWithResolution(options map[string]string, env map[string]string) (map[string]string, error)

func (*SectionPointer) ParseOptionsWithResolutionByName

func (n *SectionPointer) ParseOptionsWithResolutionByName(options map[string]string, env map[string]string) (map[string]string, error)

type SkipBlock

type SkipBlock struct {
	goldast.BaseBlock
	ConditionalImpl

	Target goldast.Node
}

func NewSkipBlock

func NewSkipBlock() *SkipBlock

func (*SkipBlock) Dump

func (n *SkipBlock) Dump(source []byte, level int)

func (*SkipBlock) GetEndSkipNode

func (n *SkipBlock) GetEndSkipNode(goldast.Node) goldast.Node

func (*SkipBlock) Kind

func (n *SkipBlock) Kind() goldast.NodeKind

func (*SkipBlock) SetTarget

func (n *SkipBlock) SetTarget(node goldast.Node)

type SpinnerMode

type SpinnerMode int
const (
	SpinnerModeVisible SpinnerMode = iota
	SpinnerModeHidden
	SpinnerModeInlineAll
	SpinnerModeInlineFirst
)

type StopFail

type StopFail struct {
	goldast.BaseBlock
	ConditionalImpl
}

func NewStopFail

func NewStopFail() *StopFail

NewRundownBlock returns a new RundownBlock node.

func (*StopFail) Dump

func (n *StopFail) Dump(source []byte, level int)

func (*StopFail) Kind

func (n *StopFail) Kind() goldast.NodeKind

Kind implements Node.Kind.

type StopOk

type StopOk struct {
	goldast.BaseBlock
	ConditionalImpl
}

func NewStopOk

func NewStopOk() *StopOk

NewRundownBlock returns a new RundownBlock node.

func (*StopOk) Dump

func (n *StopOk) Dump(source []byte, level int)

func (*StopOk) Kind

func (n *StopOk) Kind() goldast.NodeKind

Kind implements Node.Kind.

type SubEnvBlock

type SubEnvBlock struct {
	goldast.BaseBlock

	InnerBlock goldast.Node
}

func NewSubEnvBlock

func NewSubEnvBlock(innerBlock goldast.Node) *SubEnvBlock

NewRundownBlock returns a new RundownBlock node.

func (*SubEnvBlock) Dump

func (n *SubEnvBlock) Dump(source []byte, level int)

func (*SubEnvBlock) Kind

func (n *SubEnvBlock) Kind() goldast.NodeKind

Kind implements Node.Kind.

type TypeBoolean

type TypeBoolean struct{}

func (*TypeBoolean) Describe

func (t *TypeBoolean) Describe() string

func (*TypeBoolean) InputType

func (t *TypeBoolean) InputType() string

func (*TypeBoolean) Normalise

func (t *TypeBoolean) Normalise(input string) string

func (*TypeBoolean) ResolvedValue

func (t *TypeBoolean) ResolvedValue(input string) string

func (*TypeBoolean) Validate

func (t *TypeBoolean) Validate(string) error

type TypeEnum

type TypeEnum struct {
	ValidValues []string
}

func (*TypeEnum) Describe

func (t *TypeEnum) Describe() string

func (*TypeEnum) InputType

func (t *TypeEnum) InputType() string

func (*TypeEnum) Normalise

func (t *TypeEnum) Normalise(input string) string

func (*TypeEnum) ResolvedValue

func (t *TypeEnum) ResolvedValue(input string) string

func (*TypeEnum) Validate

func (t *TypeEnum) Validate(input string) error

type TypeFilename

type TypeFilename struct {
	MustExist    bool
	MustNotExist bool
}

func (*TypeFilename) Describe

func (t *TypeFilename) Describe() string

func (*TypeFilename) InputType

func (t *TypeFilename) InputType() string

func (*TypeFilename) Normalise

func (t *TypeFilename) Normalise(input string) string

func (*TypeFilename) NormaliseToPath

func (t *TypeFilename) NormaliseToPath(input string, pwd string) (string, error)

Takes the path provided in the option, and treats it as relative to the pwd, returning the absolute path.

func (*TypeFilename) ResolvedValue

func (t *TypeFilename) ResolvedValue(input string) string

func (*TypeFilename) Validate

func (t *TypeFilename) Validate(string) error

type TypeInt

type TypeInt struct{}

func (*TypeInt) Describe

func (t *TypeInt) Describe() string

func (*TypeInt) InputType

func (t *TypeInt) InputType() string

func (*TypeInt) Normalise

func (t *TypeInt) Normalise(input string) string

func (*TypeInt) ResolvedValue

func (t *TypeInt) ResolvedValue(input string) string

func (*TypeInt) Validate

func (t *TypeInt) Validate(input string) error

type TypeKV

type TypeKV struct {
	Pairs map[string]string
}

func (*TypeKV) Describe

func (t *TypeKV) Describe() string

func (*TypeKV) InputType

func (t *TypeKV) InputType() string

func (*TypeKV) Normalise

func (t *TypeKV) Normalise(input string) string

func (*TypeKV) ResolvedValue

func (t *TypeKV) ResolvedValue(input string) string

func (*TypeKV) Validate

func (t *TypeKV) Validate(input string) error

type TypeString

type TypeString struct{}

func (*TypeString) Describe

func (t *TypeString) Describe() string

func (*TypeString) InputType

func (t *TypeString) InputType() string

func (*TypeString) Normalise

func (t *TypeString) Normalise(input string) string

func (*TypeString) ResolvedValue

func (t *TypeString) ResolvedValue(input string) string

func (*TypeString) Validate

func (t *TypeString) Validate(string) error

Jump to

Keyboard shortcuts

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