exec

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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 RunnerWithProtocURL

func RunnerWithProtocURL(protocURL string) RunnerOption

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

Jump to

Keyboard shortcuts

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