Initial custom args support
This commit is contained in:
parent
afd9988c8c
commit
deab7b717d
6
main.go
6
main.go
|
@ -69,6 +69,12 @@ func main() {
|
|||
},
|
||||
Action: func(p *cli.Context) error {
|
||||
y := r.New(p)
|
||||
if p.NArg() > 0 {
|
||||
y.Projects[0].Params = make([]string, p.NArg() - 1)
|
||||
for i := 1; i < p.NArg(); i++ {
|
||||
y.Projects[0].Params[i - 1] = p.Args().Get(i)
|
||||
}
|
||||
}
|
||||
return handle(y.Fast(p))
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
|
|
|
@ -16,20 +16,26 @@ import (
|
|||
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"`
|
||||
Watcher Watcher `yaml:"app_watcher,omitempty"`
|
||||
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"`
|
||||
Params []string `yaml:"app_params,omitempty"`
|
||||
Watcher Watcher `yaml:"app_watcher,omitempty"`
|
||||
}
|
||||
|
||||
// GoRun is an implementation of the bin execution
|
||||
func (p *Project) GoRun(channel chan bool, runner chan bool, wr *sync.WaitGroup) error {
|
||||
|
||||
stop := make(chan bool, 1)
|
||||
build := exec.Command(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.Path)))
|
||||
var build *exec.Cmd
|
||||
if len(p.Params) != 0 {
|
||||
build = exec.Command(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.Path)), p.Params...)
|
||||
} else{
|
||||
build = exec.Command(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.Path)))
|
||||
}
|
||||
build.Dir = p.base
|
||||
defer func() {
|
||||
if err := build.Process.Kill(); err != nil {
|
||||
|
|
|
@ -41,6 +41,7 @@ func (h *Config) Watch() error {
|
|||
|
||||
// Fast method run a project from his working directory without makes a config file
|
||||
func (h *Config) Fast(params *cli.Context) error {
|
||||
log.Println(h.Projects[0])
|
||||
fast := h.Projects[0]
|
||||
// Takes the values from config if wd path match with someone else
|
||||
if params.Bool("config") {
|
||||
|
|
Loading…
Reference in New Issue