tools

package
v0.0.0-...-4d33260 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureInstalled

func EnsureInstalled(ctx context.Context, tools ...ExternalTool) error

EnsureInstalled checks that all tools are installed, returning an error if one or more tools are not.

func ExecuteCommand

func ExecuteCommand(ctx context.Context, commandRunner exec.CommandRunner, cmd string, args ...string) (string, error)

func ExtractVersion

func ExtractVersion(cliOutput string) (semver.Version, error)

ExtractVersion extracts a major.minor.patch version number from a typical CLI version flag output.

minor and patch version numbers are both optional, treated as 0 if not found.

func ToolInPath

func ToolInPath(name string) error

toolInPath checks to see if a program can be found on the PATH, as exec.LookPath does, returns exec.ErrNotFound in the case where os.LookPath would return exec.ErrNotFound and other errors.

func WithInstalledCheckCache

func WithInstalledCheckCache(ctx context.Context) context.Context

Types

type ErrSemver

type ErrSemver struct {
	ToolName    string
	VersionInfo VersionInfo
}

func (*ErrSemver) Error

func (err *ErrSemver) Error() string

type ExecOptions

type ExecOptions struct {
	Interactive *bool
	StdOut      io.Writer
}

ExecOptions provide configuration for how scripts are executed

type ExternalTool

type ExternalTool interface {
	CheckInstalled(ctx context.Context) error
	InstallUrl() string
	Name() string
}

func Unique

func Unique(tools []ExternalTool) []ExternalTool

Unique filters a slice of tools such that a tool with a given name only appears once.

type Script

type Script interface {
	Execute(ctx context.Context, scriptPath string, options ExecOptions) (exec.RunResult, error)
}

Utility to easily execute a bash script across platforms

type VersionInfo

type VersionInfo struct {
	MinimumVersion semver.Version
	UpdateCommand  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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