cliplugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cliplugin contains helper functionality for protoc plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(handler Handler)

Main runs the application using the OS runtime and calling os.Exit on the return value of Run.

func Run

func Run(handler Handler, runEnv *cli.RunEnv) int

Run runs the application, returning the exit code.

RunEnv will be modified to have dummy values if fields are not set.

Types

type Handler

type Handler interface {
	// Handle handles the request.
	//
	// Only system errors should be returned.
	Handle(
		stderr io.Writer,
		responseWriter ResponseWriter,
		request *plugin_go.CodeGeneratorRequest,
	)
}

Handler handles protoc plugin functionality.

type HandlerFunc

type HandlerFunc func(
	io.Writer,
	ResponseWriter,
	*plugin_go.CodeGeneratorRequest,
)

HandlerFunc is a function that implements Handler.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(
	stderr io.Writer,
	responseWriter ResponseWriter,
	request *plugin_go.CodeGeneratorRequest,
)

Handle implements Handler.

type ResponseWriter added in v0.2.0

type ResponseWriter interface {
	// WriteCodeGeneratorResponseFile adds the file to the response.
	//
	// Can be called multiple times.
	WriteCodeGeneratorResponseFile(*plugin_go.CodeGeneratorResponse_File)
	// WriteError writes the error to the response.
	//
	// Can be called multiple times. Errors will be concatenated by newlines.
	// Resulting error string will have spaces trimmed before creating the response.
	WriteError(string)
}

ResponseWriter is a response writer.

Not thread-safe.

Jump to

Keyboard shortcuts

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