Help us shape the future of Go! Take the 2026 Go Developer Survey

template

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Append

type Append struct {
	Filepath string `yaml:"filepath"`
	Content  string `yaml:"content"`
}

Append is used for adding content to files.

type Appends

type Appends []Append

Appends is the type for a slice of Append type.

type Delete

type Delete struct {
	Glob string
}

Delete is used for deteling files or directories.

type Deletes

type Deletes []Delete

Deletes is the type for a slice of Delete type.

type Edits added in v0.2.1

type Edits struct {
	Deletes  Deletes  `yaml:"deletes"`
	Moves    Moves    `yaml:"moves"`
	Appends  Appends  `yaml:"appends"`
	Replaces Replaces `yaml:"replaces"`
}

Edits define all the required edits for a template.

type Move

type Move struct {
	Src  string `yaml:"src"`
	Dest string `yaml:"dest"`
}

Move is used for moving (renaming) a file or directory.

type Moves

type Moves []Move

Moves is the type for a slice of Move type.

type Params added in v0.2.1

type Params []string

Params define required params for a template.

func (Params) Has added in v0.2.1

func (p Params) Has(param string) bool

type Replace

type Replace struct {
	Filepath string `yaml:"filepath"`
	Old      string `yaml:"old"`
	New      string `yaml:"new"`
}

Replace is used for replacing content in files.

type Replaces

type Replaces []Replace

Replaces is the type for a slice of Replace type.

type Service

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

Service

func NewService

func NewService(ui ui.UI) *Service

NewService creates a new template service.

func (*Service) Load added in v0.2.1

func (s *Service) Load(path string) error

Load reads a template YAML file and makes it available for other methods.

func (*Service) Params added in v0.2.1

func (s *Service) Params() Params

func (*Service) Template added in v0.2.1

func (s *Service) Template(inputs interface{}) (*Template, error)

type Template

type Template struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Edits       Edits  `yaml:"edits"`
}

Template has all specifications for a Basil code template.

func (*Template) Execute added in v0.2.1

func (t *Template) Execute(u ui.UI, root string) error

Execute runs all the edits defined for the template.

Jump to

Keyboard shortcuts

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