toolbox

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package toolbox is a library for automating tool dependency management. It is designed as the logical portion of the toolbox binary.

Toolbox uses a file (default "tools.go") to manage its dependency list. This is should always be a .go file, as version information is tracked via go modules, and thus tool dependencies need to be kept in a file that the go module system can scan. The tools themselves are kept in a folder (default "_tools").

Toolbox doesn't do anything massively unique, it simply automates the fiddly bits...it implements the best practices for tool automation found here: https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(packageName string, options ...Option) error

Add adds a new tool found at packageName to the vendoring system

func AddVer

func AddVer(packageName, version string, options ...Option) error

AddVer adds a new tool found at packageName with a specific version to the vendoring system

func Command

func Command(command string, args ...string) (*exec.Cmd, error)

Command creates an exec.Cmd, modifying the environment and run binary name to reflect the vendored tools.

func CommandOpts

func CommandOpts(command string, args []string, options ...Option) (*exec.Cmd, error)

CommandOpts creates an exec.Cmd, modifying the environment and run binary name to reflect the vendored tools, using the given options.

func Do

func Do(command ...string) error

Do runs the given command, using a vendored tool if applicable

func DoOpts

func DoOpts(command []string, options ...Option) error

Do runs the given command with the given options, using a vendored tool if applicable

func Remove

func Remove(packageName string, options ...Option) error

Remove stops tracking the tool from packageName in our vendoring system.

func Sync

func Sync(options ...Option) error

Sync interates through all tools that we're vendoring, and ensures that all of them are installed, and at the correct version.

Types

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

type Option

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

Option is an optional modifier to toolbox's default behavior

func BasedirOption

func BasedirOption(basedirName string) Option

BasedirOption changes the directory when using the default toolsfile and directory

func BuildFlagsOption

func BuildFlagsOption(buildFlags string) Option

BuildFlagsOption passes flags to go get and go install

func GoOption

func GoOption(goBinaryName string) Option

GoOption changes the default name/path of the "go" binary.

func GoimportsOption

func GoimportsOption(goimportsBinaryName string) Option

GoimportsOption changes the default name/path of the "goimports" binary.

func LoggerOption

func LoggerOption(logger Logger) Option

Logger option passes a logger to capture output from the subcommands

func ToolsdirOption

func ToolsdirOption(toolsdirName string) Option

TooldirOption changes the default name/path of the directory used to vendor tools

func ToolsfileOption

func ToolsfileOption(toolsfileName string) Option

ToolfileOption changes the default name/path of the file used to manage tool dependencies

type Tool

type Tool struct {
	Package    string `json:"package"`
	Version    string `json:"version"`
	BuildFlags string `json:"build_flags"`
}

func List

func List(options ...Option) ([]*Tool, error)

Jump to

Keyboard shortcuts

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