elder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package elder is a wand.Wand reference implementation that provides common Mage tasks and stores application configurations and metadata of a project.

The naming is inspired by the "Elder Wand", an extremely powerful wand made of elder wood, from the fantasy novel "Harry Potter". See https://en.wikipedia.org/wiki/Magical_objects_in_Harry_Potter#Elder_Wand for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elder

type Elder struct {
	nib.Nib
	// contains filtered or unexported fields
}

Elder is a wand.Wand reference implementation that provides common Mage tasks and stores configurations and metadata for applications of a project.

func New

func New(opts ...Option) (*Elder, error)

New creates a new elder wand.

The module name is determined automatically using the "runtime/debug" package. The absolute path to the root directory is automatically set based on the current working directory. Note that the working directory must be set manually when the "magefile" is not placed in the root directory by pointing Mage to it:

  • "-d <PATH>" option to set the directory from which "magefiles" are read (defaults to ".").
  • "-w <PATH>" option to set the working directory where "magefiles" will run (defaults to value of "-d" flag).

If any error occurs it will be of type *cast.ErrCast or *project.ErrProject.

References

func UnwrapCtx

func UnwrapCtx(ctx context.Context) (*Elder, error)

UnwrapCtx is a helper function to unwrap a elder wand from context.

func (*Elder) Bootstrap

func (e *Elder) Bootstrap() error

Bootstrap runs initialization tasks to ensure the wand is operational. This includes the installation of configured caster like cast.BinaryCaster that can handle spell incantations of kind spell.KindGoModule. When any error occurs it will be of type *cast.ErrCast.

func (*Elder) Clean

func (e *Elder) Clean(appName string, opts ...spellFSClean.Option) ([]string, error)

Clean is a spell.GoCode to remove configured filesystem paths, e.g. output data like artifacts and reports from previous development, test, production and distribution builds. It returns paths that have been cleaned along with an error of type *spell.ErrGoCode when an error occurred during the execution of the Go code. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/fs/clean" package for all available options.

func (*Elder) ExitPrintf

func (e *Elder) ExitPrintf(code int, verb nib.Verbosity, format string, args ...interface{})

ExitPrintf simplifies the logging for process exits with a suitable nib.Verbosity.

References

func (*Elder) GetAppConfig

func (e *Elder) GetAppConfig(name string) (app.Config, error)

GetAppConfig returns an application configuration. An empty application configuration is returned along with an error of type *app.ErrApp when there is no configuration in the store for the given name.

func (*Elder) GetProjectMetadata

func (e *Elder) GetProjectMetadata() project.Metadata

GetProjectMetadata returns metadata of the project.

func (*Elder) GoBuild

func (e *Elder) GoBuild(appName string, opts ...spellGoBuild.Option) error

GoBuild casts the spell incantation for the "build" command of the Go toolchain. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/golang/build" package for all available options.

func (*Elder) GoTest

func (e *Elder) GoTest(appName string, opts ...spellGoTest.Option) error

GoTest casts the spell incantation for the "test" command of the Go toolchain. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/golang/test" package for all available options.

func (*Elder) Goimports

func (e *Elder) Goimports(appName string, opts ...spellGoimports.Option) error

Goimports casts the spell incantation for the "golang.org/x/tools/cmd/goimports" Go module command that allows to update Go import lines, add missing ones and remove unreferenced ones. It also formats code in the same style as "https://pkg.go.dev/cmd/gofmt" so it can be used as a replacement. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/goimports" package for all available options.

See https://pkg.go.dev/golang.org/x/tools/cmd/goimports for more details about "goimports". The source code of "goimports" is available at https://github.com/golang/tools/tree/master/cmd/goimports.

func (*Elder) GolangCILint

func (e *Elder) GolangCILint(appName string, opts ...spellGolangCILint.Option) error

GolangCILint casts the spell incantation for the "github.com/golangci/golangci-lint/cmd/golangci-lint" Go module command, a fast, parallel runner for dozens of Go linters Go that uses caching, supports YAML configurations and has integrations with all major IDEs. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/golangcilint" package for all available options.

See https://pkg.go.dev/github.com/golangci/golangci-lint and the official website at https://golangci-lint.run for more details about "golangci-lint". The source code of "golangci-lint" is available at https://github.com/golangci/golangci-lint.

func (*Elder) Gox

func (e *Elder) Gox(appName string, opts ...spellGox.Option) error

Gox casts the spell incantation for the "github.com/mitchellh/gox" Go module command, a dead simple, no frills Go cross compile tool that behaves a lot like the standard Go toolchain "build" command. When any error occurs it will be of type *app.ErrApp or *cast.ErrCast.

See the "github.com/svengreb/wand/pkg/spell/gox" package for all available options.

See https://pkg.go.dev/github.com/mitchellh/gox for more details about "gox". The source code of the "gox" is available at https://github.com/mitchellh/gox.

func (*Elder) RegisterApp

func (e *Elder) RegisterApp(name, displayName, pathRel string) error

RegisterApp creates and stores a new application configuration. Note that the package path must be relative to the project root directory!

It returns an error of type *app.ErrApp when the application path is not relative to the project root directory, when it is not a subdirectory of it or when any other error occurs.

func (*Elder) Validate

func (e *Elder) Validate() error

Validate ensures that all casters are properly initialized and available. It returns an error of type *cast.ErrCast when the validation of any of the supported casters fails.

type Option

type Option func(*Options)

Option is a option for the wand.Wand reference implementation "elder".

func WithGoToolchainCasterOptions

func WithGoToolchainCasterOptions(opts ...castGoToolchain.Option) Option

WithGoToolchainCasterOptions sets Go toolchain caster options.

func WithGobinCasterOptions

func WithGobinCasterOptions(opts ...castGobin.Option) Option

WithGobinCasterOptions sets "gobin" caster options.

func WithNib

func WithNib(n nib.Nib) Option

WithNib sets the log-level based line printer for human-facing messages.

func WithProjectOptions

func WithProjectOptions(opts ...project.Option) Option

WithProjectOptions sets project options.

type Options

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

Options are options for the wand.Wand reference implementation "elder".

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions creates new options for the wand.Wand reference implementation "elder".

Jump to

Keyboard shortcuts

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