Documentation
¶
Index ¶
Constants ¶
const ( TypeStringInt = "int" TypeStringBool = "bool" TypeStringString = "string" )
TypeString represents type as string
Variables ¶
var CommonTemplates = []Template{
{"resource/tmpl/common/CHANGELOG.md.tmpl", "CHANGELOG.md"},
{"resource/tmpl/common/README.md.tmpl", "README.md"},
}
CommonTemplates is collection of templates which are used all frameworks.
var Frameworks = []*Framework{ { Name: "mitchellh_cli", AltNames: []string{"mitchellh"}, URL: "https://github.com/mitchellh/cli", Description: `mitchellh/cli cli is a library for implementing powerful command-line interfaces in Go. cli is the library that powers the CLI for Packer, Serf, and Consul. `, BaseTemplates: []Template{ {"resource/tmpl/mitchellh_cli/main.go.tmpl", "main.go"}, {"resource/tmpl/mitchellh_cli/version.go.tmpl", "version.go"}, {"resource/tmpl/mitchellh_cli/cli.go.tmpl", "cli.go"}, {"resource/tmpl/mitchellh_cli/commands.go.tmpl", "commands.go"}, {"resource/tmpl/mitchellh_cli/command/meta.go.tmpl", "command/meta.go"}, {"resource/tmpl/mitchellh_cli/command/version.go.tmpl", "command/version.go"}, }, CommandTemplates: []Template{ {"resource/tmpl/mitchellh_cli/command/command.go.tmpl", "command/{{ .Name }}.go"}, {"resource/tmpl/mitchellh_cli/command/command_test.go.tmpl", "command/{{ .Name }}_test.go"}, }, }, { Name: "codegangsta_cli", AltNames: []string{"codegangsta"}, URL: "https://github.com/codegangsta/cli", Description: `codegangsta/cli is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way. `, BaseTemplates: []Template{ {"resource/tmpl/codegangsta_cli/main.go.tmpl", "main.go"}, {"resource/tmpl/codegangsta_cli/version.go.tmpl", "version.go"}, {"resource/tmpl/codegangsta_cli/commands.go.tmpl", "commands.go"}, }, CommandTemplates: []Template{ {"resource/tmpl/codegangsta_cli/command/command.go.tmpl", "command/{{ .Name }}.go"}, {"resource/tmpl/codegangsta_cli/command/command_test.go.tmpl", "command/{{ .Name }}_test.go"}, }, }, { Name: "go_cmd", URL: "https://github.com/golang/go/tree/master/src/cmd/go", Description: ` `, BaseTemplates: []Template{ {"resource/tmpl/go_cmd/main.go.tmpl", "main.go"}, }, CommandTemplates: []Template{ {"resource/tmpl/go_cmd/command.go.tmpl", "{{ .Name }}.go"}, {"resource/tmpl/go_cmd/command_test.go.tmpl", "{{ .Name }}_test.go"}, }, }, { Name: "bash", URL: "", Description: ` `, BaseTemplates: []Template{ {"resource/tmpl/bash/main.sh.tmpl", "{{ .Name }}.sh"}, }, CommandTemplates: []Template{}, Hide: true, }, { Name: "flag", AltNames: []string{}, URL: "https://golang.org/pkg/flag/", Description: `Package flag implements command-line flag parsing.`, BaseTemplates: []Template{ {"resource/tmpl/flag/main.go.tmpl", "main.go"}, {"resource/tmpl/flag/version.go.tmpl", "version.go"}, {"resource/tmpl/flag/cli.go.tmpl", "cli.go"}, {"resource/tmpl/flag/cli_test.go.tmpl", "cli_test.go"}, }, CommandTemplates: []Template{}, }, }
Frameworks is collection of Framework.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
Name string
// Flags are flag for the command
Flags []Flag
// Synopsis is short help message of the command
Synopsis string
// Help is long help message of the command
Help string
}
Command store command meta information
type Executable ¶
type Executable struct {
// Name is executable name
Name string
// Owner is owner of the executable
Owner string
// Commands are commands of the executable
Commands []Command
// Flags are flags of the executable
Flags []Flag
// Version is initial version
Version string
// Description is description of the executable
Description string
}
Executable store executable meta information
type Flag ¶
type Flag struct {
// Name is flag name, this is used for flag variable name in generated code.
// Name is equal to titled LongName.
Name string
// LongName is long form of the flag name.
// This must be provided by user
LongName string
// ShortName is short form of flag name.
// This is generated automatically from LongName
ShortName string
// TypeString is flag type. This must be provided by user
TypeString string
// Default is default value.
// This is automatically generated from TypeString
Default interface{}
// Description is help message of the flag.
Description string
}
Flag stores flag meta informations
type Framework ¶
type Framework struct {
// Name is framework name
Name string
// AltName is alternative name which represent Framework
AltNames []string
// Description is description of framework
Description string
// URL is framework project URL
URL string
// BaseTemplates
BaseTemplates []Template
// CommandTemplate
CommandTemplates []Template
// If Hide is true, `list` command doesn't show
// this framework
Hide bool
}
Framework represents framework
func FrameworkByName ¶ added in v0.2.1
FrameworkByName retuns Framework
type Skeleton ¶
type Skeleton struct {
// Path is where skeleton is generated.
Path string
// If WithTest is true, also generate test code.
SkipTest bool
Framework *Framework
Executable *Executable
// ArtifactCh is channel for info output
ArtifactCh chan string
// ErrCh is channel for error output
ErrCh chan error
// Verbose enables logging output below INFO
Verbose bool
// LogWriter
LogWriter io.Writer
}
Skeleton stores meta data of skeleton
type Template ¶
type Template struct {
// Path is the path to this template.
Path string
// OutputPathTmpl is the template for outputPath.
OutputPathTmpl string
}
Template stores meta data of template
func (*Template) Exec ¶
Exec evaluate this template and write it to provided file. At First, it reads template content. Then, it generates output file path from output path template and its data. Then, it creates directory if not exist from output path. Then, it opens output file. Finally, it evaluates template contents and generate it to output file. If output file is gocode, run go fmt.
It returns an error if any.