specdir

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 4 Imported by: 26

Documentation

Index

Constants

View Source
const (
	DirPath  = PathType(false)
	FilePath = PathType(true)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileNodeProvider

type FileNodeProvider interface {
	// contains filtered or unexported methods
}

func Dir

func Dir(name NodeName, alias string, children ...FileNodeProvider) FileNodeProvider

func File

func File(name NodeName, alias string) FileNodeProvider

func OptionalDir

func OptionalDir(name NodeName, children ...FileNodeProvider) FileNodeProvider

type LayoutSpec

type LayoutSpec interface {
	FileNodeProvider

	CreateDirectoryStructure(root string, values TemplateValues, includeOptional bool) error
	RootDirName(values TemplateValues) string
	Paths(values TemplateValues, includeOptional bool) []string
	// Validate validates the provided root directory against this specification using the provided template values. If the
	// provided directory matches the specification, the function returns nil. If the function encounters an error while
	// trying to perform a verification or if the provided structure does not match the specification, an error is returned.
	Validate(root string, values TemplateValues) error
	// contains filtered or unexported methods
}

LayoutSpec represents the specification of a layout.

func NewLayoutSpec

func NewLayoutSpec(root FileNodeProvider, rootPartOfSpec bool) LayoutSpec

type Mode

type Mode int
const (
	// SpecOnly specifies that a specification should be created without performing validation or creating paths.
	SpecOnly Mode = iota
	// Validate specifies that an existing directory should be validated using the specification.
	Validate
	// Create specifies that the specification should create a directory structure that matches the specification.
	Create
)

type NodeName

type NodeName interface {
	// contains filtered or unexported methods
}

NodeName represents the name of a node and returns a value for its name given a TemplateValues object. An empty string is returned if a name cannot be generated based on the input.

func CompositeName

func CompositeName(names ...NodeName) NodeName

func LiteralName

func LiteralName(name string) NodeName

func TemplateName

func TemplateName(key string) NodeName

type PathType

type PathType bool

type SpecDir

type SpecDir interface {
	Root() string
	NamedPaths() []string
	Path(name string) string
}

SpecDir is a concrete application of a LayoutSpec. It is rooted at a directory and has TemplateValues specified.

func New

func New(rootDir string, spec LayoutSpec, values TemplateValues, mode Mode) (SpecDir, error)

type TemplateValues

type TemplateValues map[string]string

Jump to

Keyboard shortcuts

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