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 ¶
- type Elder
- func (e *Elder) Bootstrap() error
- func (e *Elder) Clean(appName string, opts ...spellFSClean.Option) ([]string, error)
- func (e *Elder) ExitPrintf(code int, verb nib.Verbosity, format string, args ...interface{})
- func (e *Elder) GetAppConfig(name string) (app.Config, error)
- func (e *Elder) GetProjectMetadata() project.Metadata
- func (e *Elder) GoBuild(appName string, opts ...spellGoBuild.Option) error
- func (e *Elder) GoTest(appName string, opts ...spellGoTest.Option) error
- func (e *Elder) Goimports(appName string, opts ...spellGoimports.Option) error
- func (e *Elder) GolangCILint(appName string, opts ...spellGolangCILint.Option) error
- func (e *Elder) Gox(appName string, opts ...spellGox.Option) error
- func (e *Elder) RegisterApp(name, displayName, pathRel string) error
- func (e *Elder) Validate() error
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elder ¶
Elder is a wand.Wand reference implementation that provides common Mage tasks and stores configurations and metadata for applications of a project.
func New ¶
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 (*Elder) Bootstrap ¶
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 ¶
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 ¶
ExitPrintf simplifies the logging for process exits with a suitable nib.Verbosity.
References
func (*Elder) GetAppConfig ¶
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 ¶
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 ¶
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 ¶
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.
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 ¶
WithGobinCasterOptions sets "gobin" caster options.
func WithProjectOptions ¶
WithProjectOptions sets project options.