This commit is contained in:
alessio 2017-06-16 11:15:56 +02:00
parent 350bdbb4a6
commit e2c06878f5
6 changed files with 35 additions and 28 deletions

View File

@ -80,7 +80,6 @@ func main() {
if err := r.Read(&r); err != nil { if err := r.Read(&r); err != nil {
return err return err
} }
// increase the file limit // increase the file limit
if r.Config.Flimit != 0 { if r.Config.Flimit != 0 {
if err := r.Flimit(); err != nil { if err := r.Flimit(); err != nil {
@ -111,6 +110,7 @@ func main() {
Description: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one", Description: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."}, &cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "", Usage: "Run a project by its name."},
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."}, &cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
&cli.BoolFlag{Name: "generate", Aliases: []string{"g"}, Value: false, Usage: "Enable go generate."}, &cli.BoolFlag{Name: "generate", Aliases: []string{"g"}, Value: false, Usage: "Enable go generate."},
&cli.BoolFlag{Name: "build", Aliases: []string{"b"}, Value: false, Usage: "Enable go build."}, &cli.BoolFlag{Name: "build", Aliases: []string{"b"}, Value: false, Usage: "Enable go build."},
@ -121,6 +121,14 @@ func main() {
&cli.BoolFlag{Name: "no-config", Aliases: []string{"nc"}, Value: false, Usage: "Ignore existing configurations."}, &cli.BoolFlag{Name: "no-config", Aliases: []string{"nc"}, Value: false, Usage: "Ignore existing configurations."},
}, },
Action: func(p *cli.Context) error { Action: func(p *cli.Context) error {
c := r
if p.String("name") != ""{
for index, project := range r.Blueprint.Projects{
if project.Name == p.String("name"){
c.Blueprint.Projects = []watcher.Project{r.Blueprint.Projects[index]}
}
}
}
if p.Bool("legacy") { if p.Bool("legacy") {
r.Config.Legacy = settings.Legacy{ r.Config.Legacy = settings.Legacy{
Status: p.Bool("legacy"), Status: p.Bool("legacy"),
@ -136,13 +144,13 @@ func main() {
return err return err
} }
} }
if err := r.Server.Start(p); err != nil { if err := c.Server.Start(p); err != nil {
return err return err
} }
if err := r.Blueprint.Run(); err != nil { if err := c.Blueprint.Run(p); err != nil {
return err return err
} }
if err := r.Record(r); err != nil { if err := r.Record(c); err != nil {
return err return err
} }
return nil return nil

View File

@ -3,7 +3,6 @@ package settings
import ( import (
"os" "os"
"time" "time"
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
) )

View File

@ -9,7 +9,7 @@ import (
) )
// Run launches the toolchain for each project // Run launches the toolchain for each project
func (h *Blueprint) Run() error { func (h *Blueprint) Run(p *cli.Context) error {
err := h.check() err := h.check()
if err == nil { if err == nil {
// loop projects // loop projects

View File

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"github.com/tockins/realize/style"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -12,7 +13,6 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/tockins/realize/style"
) )
// GoRun is an implementation of the bin execution // GoRun is an implementation of the bin execution

View File

@ -36,7 +36,7 @@ type Project struct {
base string base string
Name string `yaml:"name" json:"name"` Name string `yaml:"name" json:"name"`
Path string `yaml:"path" json:"path"` Path string `yaml:"path" json:"path"`
Cmds Cmds `yaml:"cmds" json:"cmds"` Cmds Cmds `yaml:"commands" json:"commands"`
Args []string `yaml:"args,omitempty" json:"args,omitempty"` Args []string `yaml:"args,omitempty" json:"args,omitempty"`
Watcher Watcher `yaml:"watcher" json:"watcher"` Watcher Watcher `yaml:"watcher" json:"watcher"`
Streams Streams `yaml:"streams" json:"streams"` Streams Streams `yaml:"streams" json:"streams"`

View File

@ -3,19 +3,19 @@ package watcher
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/fsnotify/fsnotify"
"github.com/tockins/realize/style"
"log" "log"
"math/big" "math/big"
"os" "os"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
"reflect"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
"time" "time"
"reflect"
"github.com/fsnotify/fsnotify"
"github.com/tockins/realize/style"
) )
var msg string var msg string