Documentation
¶
Index ¶
Constants ¶
View Source
const ( // CLI with commands Framework_go_cmd = 100 + iota Framework_codegangsta_cli Framework_mitchellh_cli // CLI only with flag Framework_flag = 1000 + iota )
Variables ¶
View Source
var (
CommonTemplates = []Template{
{"resource/tmpl/common/CHANGELOG.md.tmpl", "CHANGELOG.md"},
{"resource/tmpl/common/README.md.tmpl", "README.md"},
}
)
Functions ¶
func CommandTemplates ¶
CommandTempaltes returns command Tempalte based on framework ID. The first return value is command Tempalte. The second return value is command test Tempalte.
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
}
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
}
type Skeleton ¶
type Skeleton struct {
// Path is where skeleton is generated.
Path string
// Framework represent which cli package is used.
// Framework ID is defined on framework_tempalte.go
Framework int
// If WithTest is true, also generate test code.
SkipTest bool
Executable *Executable
}
type Template ¶
type Template struct {
// Path is the path to this template.
Path string
// OutputPathTmpl is the template for outputPath.
OutputPathTmpl string
}
func FrameworkTemplates ¶
FrameworkTempaltes returns framework Template based on framework ID.
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.
Click to show internal directories.
Click to hide internal directories.