Documentation ¶
Index ¶
- func EditFile(filePath string, f func(io.Reader, io.Writer) error) (retErr error)
- func FileExists(filename string) bool
- func FindUp(start, path string) string
- func Glob(patterns []string) ([]*FileAsset, []*RegexpInfo, error)
- func Globexp(glob string) *regexp.Regexp
- func Load(src, dest string)
- func Outdated(srcGlobs, destGlobs []string) bool
- func PackageName(sourceFile string) (string, error)
- func PartitionKV(r io.Reader, prefix string, assignment string) ([]map[string]string, error)
- func PatternRoot(s string) string
- func ProgressBarConfig(bar *pb.ProgressBar, prefix string)
- func StrTemplate(src string, data map[string]interface{}) (string, error)
- func StripPackageCommentsForFile(filePath string) error
- func Template(src string, dest string, data map[string]interface{})
- type FileAsset
- type ProgressBar
- type RegexpInfo
- type WatchCriteria
- type WatchCriterion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Glob ¶
func Glob(patterns []string) ([]*FileAsset, []*RegexpInfo, error)
Glob returns files and dirctories that match patterns. Patterns must use slashes, even Windows.
Special chars.
/**/ - match zero or more directories {a,b} - match a or b, no spaces * - match any non-separator char ? - match a single non-separator char **/ - match any directory, start of pattern only /** - match any this directory, end of pattern only ! - removes files from resultset, start of pattern only
func Globexp ¶
Globexp builds a regular express from from extended glob pattern and then returns a Regexp object.
func Outdated ¶
Outdated determines if ANY src has been modified after ANY dest.
For example: *.go.html -> *.go
If any go.html has changed then generate go files.
func PackageName ¶
PackageName determines the package name from sourceFile if it is within $GOPATH
func PartitionKV ¶
PartitionKV partitions a reader then parses key-value meta using an assignment string.
Example ¶
PartitionKV(buf.NewBufferString(`
--@ key=SelectUser SELECT * FROM users;
`, "--@", "=") => [{"_kind": "key", "key": "SelectUser", "_body": "SELECT * FROM users;"}]
func PatternRoot ¶
PatternRoot gets a real directory root from a pattern. The directory returned is used as the start location for globbing.
func ProgressBarConfig ¶
func ProgressBarConfig(bar *pb.ProgressBar, prefix string)
func StrTemplate ¶
StrTemplate reads a go template and writes it to dist given data.
func StripPackageCommentsForFile ¶
StripPackageCommentsForFile strips the package comments for a file.
TODO(pedge): not real verification that we are in package comments, just takes the first block comment in the file and eliminates it.
Types ¶
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
func (*ProgressBar) TrackProgress ¶
func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser
type RegexpInfo ¶
RegexpInfo contains additional info about the Regexp created by a glob pattern.
func (*RegexpInfo) MatchString ¶
func (ri *RegexpInfo) MatchString(s string) bool
MatchString matches a string with either a regexp or direct string match
type WatchCriteria ¶
type WatchCriteria struct {
Items []*WatchCriterion
}
WatchCriteria is the set of criterion to watch one or more glob patterns.
func EffectiveCriteria ¶
func EffectiveCriteria(globs ...string) (*WatchCriteria, error)
EffectiveCriteria is the minimum set of criteria to watch the items in patterns
func (*WatchCriteria) Matches ¶
func (cr *WatchCriteria) Matches(pth string) bool
Matches determines if pth is matched by internal criteria.
func (*WatchCriteria) Roots ¶
func (cr *WatchCriteria) Roots() []string
Roots returns the root paths of all criteria.
type WatchCriterion ¶
type WatchCriterion struct { // Root is the root directory to start watching. Root string // Includes are the regexp for including files IncludesRegexp []*regexp.Regexp // Excludes are the regexp for excluding files ExcludesRegexp []*regexp.Regexp Includes []string Excludes []string }
WatchCriterion is the criteria needed to test if a file matches a pattern.