luci: Index | Files

package svctool

import ""

Package svctool implements svcmux/svcdec tools command line parsing


Package Files

parser.go tool.go

type Generator Uses

type Generator func(c context.Context, a *GeneratorArgs) error

type GeneratorArgs Uses

type GeneratorArgs struct {
    PackageName  string
    Services     []*Service
    ExtraImports []Import
    Out          io.Writer

GeneratorArgs is passed to the function responsible for generating files.

type Import Uses

type Import struct {
    Name string
    Path string

type Method Uses

type Method struct {
    Name       string
    Node       *ast.Field
    InputType  string
    OutputType string

type Service Uses

type Service struct {
    TypeName string
    Node     *ast.InterfaceType
    Methods  []*Method

Service contains the result of parsing the generated code for a pRPC service.

type Tool Uses

type Tool struct {
    // Name of the tool, e.g. "svcmux" or "svcdec".
    Name string
    // OutputFilenameSuffix is the suffix of generated file names,
    // e.g. "mux" or "dec" for foo_mux.go or foo_dec.go.
    OutputFilenameSuffix string

    // Types are type names from the Go package defined by Dir or FileNames.
    Types []string
    // Output is the base name for the output file.
    Output string
    // Dir is a Go package's directory.
    Dir string
    // FileNames is a list of source files from a single Go package.
    FileNames []string

Tool is a helper class for svcmux and svcdec.

func (*Tool) Main Uses

func (t *Tool) Main(args []string, f Generator)

Main does some setup (arg parsing, logging), calls t.Run, prints any errors and exits.

func (*Tool) ParseArgs Uses

func (t *Tool) ParseArgs(args []string)

ParseArgs parses command arguments. Exits if they are invalid.

func (*Tool) Run Uses

func (t *Tool) Run(c context.Context, f Generator) error

Run parses Go files and generates a new file using f.

Package svctool imports 18 packages (graph) and is imported by 4 packages. Updated 2021-01-21. Refresh now. Tools for package owners.