2016-09-01 22:17:19 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2016-09-18 11:50:15 +00:00
|
|
|
"github.com/fatih/color"
|
2016-09-01 22:17:19 +00:00
|
|
|
"log"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
2016-09-18 11:50:15 +00:00
|
|
|
var Green, Red, RedS, Blue, BlueS, Yellow, YellowS, Magenta, MagentaS = color.New(color.FgGreen, color.Bold).SprintFunc(),
|
2016-09-01 22:17:19 +00:00
|
|
|
color.New(color.FgRed, color.Bold).SprintFunc(),
|
|
|
|
color.New(color.FgRed).SprintFunc(),
|
|
|
|
color.New(color.FgBlue, color.Bold).SprintFunc(),
|
|
|
|
color.New(color.FgBlue).SprintFunc(),
|
|
|
|
color.New(color.FgYellow, color.Bold).SprintFunc(),
|
|
|
|
color.New(color.FgYellow).SprintFunc(),
|
|
|
|
color.New(color.FgMagenta, color.Bold).SprintFunc(),
|
|
|
|
color.New(color.FgMagenta).SprintFunc()
|
|
|
|
|
2016-09-18 11:50:15 +00:00
|
|
|
// Log struct
|
|
|
|
type logWriter struct{}
|
|
|
|
|
2016-09-01 22:17:19 +00:00
|
|
|
// Projects struct contains a projects list
|
|
|
|
type Blueprint struct {
|
2016-09-18 11:50:15 +00:00
|
|
|
Projects []Project `yaml:"projects,omitempty"`
|
2016-09-01 22:17:19 +00:00
|
|
|
Files map[string]string `yaml:"-"`
|
2016-09-18 13:35:44 +00:00
|
|
|
Sync chan string
|
2016-09-01 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Project defines the informations of a single project
|
|
|
|
type Project struct {
|
|
|
|
reload time.Time
|
|
|
|
base string
|
|
|
|
Name string `yaml:"app_name,omitempty"`
|
|
|
|
Path string `yaml:"app_path,omitempty"`
|
|
|
|
Run bool `yaml:"app_run,omitempty"`
|
|
|
|
Bin bool `yaml:"app_bin,omitempty"`
|
|
|
|
Build bool `yaml:"app_build,omitempty"`
|
|
|
|
Fmt bool `yaml:"app_fmt,omitempty"`
|
|
|
|
Test bool `yaml:"app_test,omitempty"`
|
|
|
|
Params []string `yaml:"app_params,omitempty"`
|
|
|
|
Watcher Watcher `yaml:"app_watcher,omitempty"`
|
2016-09-18 11:50:15 +00:00
|
|
|
Buffer Buffer `yaml:"-"`
|
|
|
|
parent *Blueprint
|
2016-09-01 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Watcher struct defines the livereload's logic
|
|
|
|
type Watcher struct {
|
|
|
|
// different before and after on re-run?
|
|
|
|
Before []string `yaml:"before,omitempty"`
|
|
|
|
After []string `yaml:"after,omitempty"`
|
|
|
|
Paths []string `yaml:"paths,omitempty"`
|
|
|
|
Ignore []string `yaml:"ignore_paths,omitempty"`
|
|
|
|
Exts []string `yaml:"exts,omitempty"`
|
|
|
|
Preview bool `yaml:"preview,omitempty"`
|
|
|
|
Output map[string]bool `yaml:"output,omitempty"`
|
|
|
|
}
|
|
|
|
|
2016-09-17 14:46:26 +00:00
|
|
|
// Buffer struct for buffering outputs
|
|
|
|
type Buffer struct {
|
|
|
|
StdOut []string
|
|
|
|
StdLog []string
|
|
|
|
StdErr []string
|
|
|
|
}
|
|
|
|
|
2016-09-01 22:17:19 +00:00
|
|
|
// Initialize the application
|
|
|
|
func init() {
|
|
|
|
log.SetFlags(0)
|
|
|
|
log.SetOutput(new(logWriter))
|
|
|
|
}
|