Back to

Package exec

Latest Go to latest

The latest major version is .

Published: Sep 17, 2018 | License: MIT | Module:


Package exec brings all the functionality of Prototool together in a format easily consumable by CLI libraries. It is effectively the glue between internal/cmd and all other packages.


type ExitError

type ExitError struct {
	Code    int
	Message string

ExitError is an error that signals to exit with a certain code.

func (*ExitError) Error

func (e *ExitError) Error() string

Error implements error.

type Runner

type Runner interface {
	Init(args []string, uncomment bool) error
	Create(args []string, pkg string) error
	Version() error
	Download() error
	Clean() error
	Files(args []string) error
	Compile(args []string, dryRun bool) error
	Gen(args []string, dryRun bool) error
	DescriptorProto(args []string) error
	FieldDescriptorProto(args []string) error
	ServiceDescriptorProto(args []string) error
	Lint(args []string, listAllLinters bool, listLinters bool) error
	ListLintGroup(group string) error
	ListAllLintGroups() error
	Format(args []string, overwrite, diffMode, lintMode, fix bool) error
	BinaryToJSON(args []string) error
	JSONToBinary(args []string) error
	All(args []string, disableFormat, disableLint, fix bool) error
	GRPC(args, headers []string, address, method, data, callTimeout, connectTimeout, keepaliveTime string, stdin bool) error

Runner runs commands.

The args given are the args from the command line. Each additional parameter generally refers to a command-specific flag.

func NewRunner

func NewRunner(workDirPath string, input io.Reader, output io.Writer, options ...RunnerOption) Runner

NewRunner returns a new Runner.

workDirPath should generally be the current directory. input and output generally refer to stdin and stdout.

type RunnerOption

type RunnerOption func(*runner)

RunnerOption is an option for a new Runner.

func RunnerWithCachePath

func RunnerWithCachePath(cachePath string) RunnerOption

RunnerWithCachePath returns a RunnerOption that uses the given cache path.

func RunnerWithConfigData

func RunnerWithConfigData(configData string) RunnerOption

RunnerWithConfigData returns a RunnerOption that uses the given config path.

func RunnerWithJSON

func RunnerWithJSON() RunnerOption

RunnerWithJSON returns a RunnerOption that will print failures as JSON.

func RunnerWithLogger

func RunnerWithLogger(logger *zap.Logger) RunnerOption

RunnerWithLogger returns a RunnerOption that uses the given logger.

The default is to use zap.NewNop().

func RunnerWithPrintFields

func RunnerWithPrintFields(printFields string) RunnerOption

RunnerWithPrintFields returns a RunnerOption that uses the given colon-separated print fields. The default is filename:line:column:message.

func RunnerWithProtocBinPath

func RunnerWithProtocBinPath(protocBinPath string) RunnerOption

RunnerWithProtocBinPath returns a RunnerOption that uses the given protoc binary path.

func RunnerWithProtocURL

func RunnerWithProtocURL(protocURL string) RunnerOption

RunnerWithProtocURL returns a RunnerOption that uses the given protoc zip file URL.

func RunnerWithProtocWKTPath

func RunnerWithProtocWKTPath(protocWKTPath string) RunnerOption

RunnerWithProtocWKTPath returns a RunnerOption that uses the given path to include the well-known types.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier