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 {
return err
}
// increase the file limit
if r.Config.Flimit != 0 {
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",
Flags: []cli.Flag{
&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: "generate", Aliases: []string{"g"}, Value: false, Usage: "Enable go generate."},
&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."},
},
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") {
r.Config.Legacy = settings.Legacy{
Status: p.Bool("legacy"),
@ -136,13 +144,13 @@ func main() {
return err
}
}
if err := r.Server.Start(p); err != nil {
if err := c.Server.Start(p); err != nil {
return err
}
if err := r.Blueprint.Run(); err != nil {
if err := c.Blueprint.Run(p); err != nil {
return err
}
if err := r.Record(r); err != nil {
if err := r.Record(c); err != nil {
return err
}
return nil

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ type Project struct {
base string
Name string `yaml:"name" json:"name"`
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"`
Watcher Watcher `yaml:"watcher" json:"watcher"`
Streams Streams `yaml:"streams" json:"streams"`

View File

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