2016-09-01 22:17:19 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2016-11-01 09:56:12 +00:00
|
|
|
c "github.com/tockins/realize/settings"
|
2016-09-01 22:17:19 +00:00
|
|
|
"log"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
2016-09-18 11:50:15 +00:00
|
|
|
// Log struct
|
2016-11-01 09:56:12 +00:00
|
|
|
type logWriter struct {
|
|
|
|
c.Colors
|
|
|
|
}
|
2016-09-18 11:50:15 +00:00
|
|
|
|
2016-09-01 22:17:19 +00:00
|
|
|
// Projects struct contains a projects list
|
|
|
|
type Blueprint struct {
|
2016-11-01 09:56:12 +00:00
|
|
|
*c.Settings `yaml:"-"`
|
|
|
|
Projects []Project `yaml:"projects,omitempty"`
|
|
|
|
Sync chan string `yaml:"-"`
|
2016-09-01 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Project defines the informations of a single project
|
|
|
|
type Project struct {
|
2016-11-01 09:56:12 +00:00
|
|
|
c.Settings `yaml:"-"`
|
2016-10-14 08:47:43 +00:00
|
|
|
LastChangedOn time.Time `yaml:"-"`
|
2016-09-22 22:41:42 +00:00
|
|
|
base string
|
2016-11-11 16:23:17 +00:00
|
|
|
Name string `yaml:"name"`
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
Run bool `yaml:"run"`
|
|
|
|
Bin bool `yaml:"bin"`
|
|
|
|
Generate bool `yaml:"generate"`
|
|
|
|
Build bool `yaml:"build"`
|
|
|
|
Fmt bool `yaml:"fmt"`
|
|
|
|
Test bool `yaml:"test"`
|
|
|
|
Params []string `yaml:"params"`
|
|
|
|
Watcher Watcher `yaml:"watcher"`
|
|
|
|
Cli Cli `yaml:"cli"`
|
|
|
|
File File `yaml:"file"`
|
2016-09-22 22:41:42 +00:00
|
|
|
Buffer Buffer `yaml:"-"`
|
|
|
|
parent *Blueprint
|
2016-11-01 09:56:12 +00:00
|
|
|
path string
|
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?
|
2016-11-11 16:23:17 +00:00
|
|
|
Before []string `yaml:"before"`
|
|
|
|
After []string `yaml:"after"`
|
|
|
|
Paths []string `yaml:"paths"`
|
|
|
|
Ignore []string `yaml:"ignore_paths"`
|
|
|
|
Exts []string `yaml:"exts"`
|
|
|
|
Preview bool `yaml:"preview"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Cli struct {
|
|
|
|
Streams bool `yaml:"streams"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type File struct {
|
|
|
|
Streams bool `yaml:"streams"`
|
|
|
|
Logs bool `yaml:"logs"`
|
|
|
|
Errors bool `yaml:"errors"`
|
2016-09-01 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
2016-09-17 14:46:26 +00:00
|
|
|
// Buffer struct for buffering outputs
|
|
|
|
type Buffer struct {
|
2016-10-14 08:47:43 +00:00
|
|
|
StdOut []BufferOut
|
|
|
|
StdLog []BufferOut
|
|
|
|
StdErr []BufferOut
|
|
|
|
}
|
|
|
|
|
|
|
|
type BufferOut struct {
|
2016-11-17 00:02:25 +00:00
|
|
|
Time time.Time
|
|
|
|
Text string
|
|
|
|
Path string
|
|
|
|
Type string
|
|
|
|
Stream string
|
|
|
|
Errors []string
|
2016-09-17 14:46:26 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 22:17:19 +00:00
|
|
|
// Initialize the application
|
|
|
|
func init() {
|
|
|
|
log.SetFlags(0)
|
|
|
|
log.SetOutput(new(logWriter))
|
|
|
|
}
|