gengo: Index | Files

package args

import ""

Package args has common command-line flags for generation programs.


Package Files


func DefaultSourceTree Uses

func DefaultSourceTree() string

DefaultSourceTree returns the /src directory of the first entry in $GOPATH. If $GOPATH is empty, it returns "./". Useful as a default output location.

type GeneratorArgs Uses

type GeneratorArgs struct {
    // Which directories to parse.
    InputDirs []string

    // Source tree to write results to.
    OutputBase string

    // Package path within the source tree.
    OutputPackagePath string

    // Output file name.
    OutputFileBaseName string

    // Where to get copyright header text.
    GoHeaderFilePath string

    // If GeneratedByCommentTemplate is set, generate a "Code generated by" comment
    // below the bloilerplate, of the format defined by this string.
    // Any instances of "GENERATOR_NAME" will be replaced with the name of the code generator.
    GeneratedByCommentTemplate string

    // If true, only verify, don't write anything.
    VerifyOnly bool

    // If true, include *_test.go files
    IncludeTestFiles bool

    // GeneratedBuildTag is the tag used to identify code generated by execution
    // of this type. Each generator should use a different tag, and different
    // groups of generators (external API that depends on Kube generations) should
    // keep tags distinct as well.
    GeneratedBuildTag string

    // Any custom arguments go here
    CustomArgs interface{}
    // contains filtered or unexported fields

GeneratorArgs has arguments that are passed to generators.

func Default Uses

func Default() *GeneratorArgs

Default returns a defaulted GeneratorArgs. You may change the defaults before calling AddFlags.

func (*GeneratorArgs) AddFlags Uses

func (g *GeneratorArgs) AddFlags(fs *pflag.FlagSet)

func (*GeneratorArgs) Execute Uses

func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error

Execute implements main(). If you don't need any non-default behavior, use as: args.Default().Execute(...)

func (*GeneratorArgs) InputIncludes Uses

func (g *GeneratorArgs) InputIncludes(p *types.Package) bool

InputIncludes returns true if the given package is a (sub) package of one of the InputDirs.

func (*GeneratorArgs) LoadGoBoilerplate Uses

func (g *GeneratorArgs) LoadGoBoilerplate() ([]byte, error)

LoadGoBoilerplate loads the boilerplate file passed to --go-header-file.

func (*GeneratorArgs) NewBuilder Uses

func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error)

NewBuilder makes a new parser.Builder and populates it with the input directories.

func (*GeneratorArgs) WithoutDefaultFlagParsing Uses

func (g *GeneratorArgs) WithoutDefaultFlagParsing() *GeneratorArgs

WithoutDefaultFlagParsing disables implicit addition of command line flags and parsing.

Package args imports 15 packages (graph) and is imported by 137 packages. Updated 2020-01-11. Refresh now. Tools for package owners.