tool

package
v0.0.0-...-53353bc Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package tool contains abstractions for working with developer tools. In particular:

1) It contains global variables that can be used to store attributes of a tool. Automated builds can set these values to something meaningful as follows:

go build -ldflags "-X github.com/btwiuse/jiri/tool.<key> <value>" github.com/btwiuse/jiri/<tool>

2) It provides the Context type, which encapsulates the state and abstractions commonly accessed throughout the lifetime of a tool invocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context represents an execution context of a tool command invocation. Its purpose is to enable sharing of state throughout the lifetime of a command invocation.

func NewContext

func NewContext(opts ContextOpts) *Context

NewContext is the Context factory.

func NewContextFromEnv

func NewContextFromEnv(env *cmdline.Env) *Context

NewContextFromEnv returns a new context instance based on the given cmdline environment.

func NewDefaultContext

func NewDefaultContext() *Context

NewDefaultContext returns a new default context.

func (Context) Clone

func (ctx Context) Clone(opts ContextOpts) *Context

Clone creates a clone of the given context, overriding select settings using the given options.

func (Context) Env

func (ctx Context) Env() map[string]string

Env returns the environment of the context.

func (Context) Stderr

func (ctx Context) Stderr() io.Writer

Stderr returns the standard error output of the context.

func (Context) Stdin

func (ctx Context) Stdin() io.Reader

Stdin returns the standard input of the context.

func (Context) Stdout

func (ctx Context) Stdout() io.Writer

Stdout returns the standard output of the context.

func (Context) Timer

func (ctx Context) Timer() *timing.Timer

Timer returns the timer associated with the context, which may be nil.

func (Context) TimerPop

func (ctx Context) TimerPop()

TimerPop calls ctx.Timer().Pop(), only if the Timer is non-nil.

func (Context) TimerPush

func (ctx Context) TimerPush(name string)

TimerPush calls ctx.Timer().Push(name), only if the Timer is non-nil.

type ContextOpts

type ContextOpts struct {
	Env    map[string]string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Timer  *timing.Timer
}

ContextOpts records the context options.

Jump to

Keyboard shortcuts

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