make

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package make provides the go-make command implementation.

Index

Constants

View Source
const (
	// EnvGoMakeConfig provides the name of the go-make config environment
	// variable.
	EnvGoMakeConfig = "GOMAKE_CONFIG"
	// EnvGoPath provides the name of the genera go path environment variable.
	EnvGoPath = "GOPATH"
	// Makefile provides the name of the base makefile to be executed by
	// go-make.
	Makefile = "Makefile.base"
	// bashCompletion provides the bash completion script for go-make.
	BashCompletion = "### bash completion for go-make\n" +
		"function __complete_go-make() {\n" +
		"	COMPREPLY=($(compgen -W \"$(go-make show-targets 2>/dev/null)\" \\\n" +
		"		-- \"${COMP_WORDS[COMP_CWORD]}\"));\n" +
		"}\n" +
		"complete -F __complete_go-make go-make;\n"
)
View Source
const (
	ExitSuccess       int = 0
	ExitGitFailure    int = 1
	ExitConfigFailure int = 2
	ExitTargetFailure int = 3
)

Available exit code constants.

Variables

View Source
var CmdArgRegex = regexp.MustCompile(
	`^(call|show|git-|test-|lint|run-|version-|update).*$`)

CmdArgRegex is the regular expression that match commands with arguments that will be transformed into a `ARGS` variable.

View Source
var ErrNotFound = errors.New("version not found")

ErrNotFound represent a version not found error.

Functions

func AbsPath added in v0.0.47

func AbsPath(dir string) string

AbsPath returns the absolute path of given directory.

func CmdGitTop added in v0.0.47

func CmdGitTop() []string

CmdGitTop creates the argument array of a `git rev-parse` command to get the root path of the current git repository.

func CmdGoInstall added in v0.0.26

func CmdGoInstall(path, version string) []string

CmdGoInstall creates the argument array of a `go install <path>@<version>` command.

func CmdMakeTargets

func CmdMakeTargets(file string, args ...string) []string

CmdMakeTargets creates the argument array of a `make --file <Makefile> <targets...>` command using the given makefile name amd argument list.

func CmdTestDir added in v0.0.26

func CmdTestDir(path string) []string

CmdTestDir creates the argument array of a `test -d <path>` command. We use this to test if a directory exists, since it allows us to mock the check.

func GetEnvDefault added in v0.0.29

func GetEnvDefault(key, value string) string

GetEnvDefault returns the value of the environment variable with given key or the given default value, if the environment variable is not set.

func GoMakePath added in v0.0.26

func GoMakePath(path, version string) string

GoMakePath returns the path to the go-make config directory.

func Make

func Make(
	stdin io.Reader, stdout, stderr io.Writer, info *info.Info,
	config, wd string, env []string, args ...string,
) int

Make runs the go-make command with given build information, standard output writer, standard error writer, and command arguments.

func NewErrCallFailed

func NewErrCallFailed(path string, args []string, err error) error

NewErrCallFailed wraps the error of a failed command call.

func NewErrNotFound

func NewErrNotFound(path, version string, err error) error

NewErrNotFound wraps the error of failed command to install the requested go-mock config version.

Types

type GoMake

type GoMake struct {
	// Info provides the build information of go-make.
	Info *info.Info
	// Executor provides the command executor.
	Executor cmd.Executor
	// Logger provides the logger.
	Logger log.Logger
	// Stdin provides the standard input reader.
	Stdin io.Reader
	// Stdout provides the standard output writer.
	Stdout io.Writer
	// Stderr provides the standard error writer.
	Stderr io.Writer
	// Config provides the go-make config argument.
	Config string
	// Env provides the additional environment variables.
	Env []string

	// The actual working directory.
	WorkDir string
	// The version of the go-make config.
	ConfigVersion string
	// The directory of the go-make config.
	ConfigDir string
	// The path to the go-make config Makefile.
	Makefile string
	// Trace provides the flags to trace calls.
	Trace bool
}

GoMake provides the default `go-make` application context.

func NewGoMake

func NewGoMake(
	stdin io.Reader, stdout, stderr io.Writer,
	info *info.Info, config, wd string, env ...string,
) *GoMake

NewGoMake returns a new default `go-make` service context with given standard input reader, standard output writer, standard error writer, build information, config setup, working directory and environment variables.

func (*GoMake) Make

func (gm *GoMake) Make(args ...string) (int, error)

Make runs the go-make command with given arguments and return the exit code and error.

Jump to

Keyboard shortcuts

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