tool

package
v0.0.0-...-abfb8b1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: BSD-3-Clause Imports: 10 Imported by: 18

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 v.io/jiri/tool.<key> <value>" v.io/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

View Source
var (
	// Flags for running commands.
	ColorFlag   bool
	VerboseFlag bool

	// Flags for working with projects.
	ManifestFlag string
)
View Source
var Name string = ""

Name identifies the name of a tool.

View Source
var Version string = "manual-build"

Version identifies the version of a tool.

Functions

func InitializeProjectFlags

func InitializeProjectFlags(flags *flag.FlagSet)

InitializeRunFlags initializes flags for working with projects.

func InitializeRunFlags

func InitializeRunFlags(flags *flag.FlagSet)

InitializeRunFlags initializes flags for running commands.

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) Color

func (ctx Context) Color() bool

Color returns the color setting of the context.

func (Context) Env

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

Env returns the environment of the context.

func (Context) Gerrit

func (ctx Context) Gerrit(host *url.URL) *gerrit.Gerrit

Gerrit returns the Gerrit instance of the context.

func (Context) Jenkins

func (ctx Context) Jenkins(host string) (*jenkins.Jenkins, error)

Jenkins returns a new Jenkins instance that can be used to communicate with a Jenkins server running at the given host.

func (Context) Manifest

func (ctx Context) Manifest() string

Manifest returns the manifest of the context.

func (Context) NewSeq

func (ctx Context) NewSeq() runutil.Sequence

NewSeq returns a new instance of Sequence initialized using the options stored in 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.

func (Context) Verbose

func (ctx Context) Verbose() bool

Verbose returns the verbosity setting of the context.

type ContextOpts

type ContextOpts struct {
	Color    *bool
	Manifest *string
	Env      map[string]string
	Stdin    io.Reader
	Stdout   io.Writer
	Stderr   io.Writer
	Verbose  *bool
	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