projects paths fixed
This commit is contained in:
parent
5db56eff23
commit
1ec7938974
9
main.go
9
main.go
|
@ -33,8 +33,7 @@ func main() {
|
||||||
wd := func() string {
|
wd := func() string {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(r.Red(err))
|
log.Fatal(r.Red(err))
|
||||||
return "/"
|
|
||||||
}
|
}
|
||||||
wd := strings.Split(dir, "/")
|
wd := strings.Split(dir, "/")
|
||||||
return wd[len(wd)-1]
|
return wd[len(wd)-1]
|
||||||
|
@ -75,7 +74,7 @@ func main() {
|
||||||
},
|
},
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
y := r.New(p)
|
y := r.New(p)
|
||||||
y.Projects[0].Path = wd()
|
y.Projects[0].Path = "/"
|
||||||
return handle(y.Fast(p))
|
return handle(y.Fast(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
|
@ -89,8 +88,8 @@ func main() {
|
||||||
Aliases: []string{"a"},
|
Aliases: []string{"a"},
|
||||||
Usage: "Add another project",
|
Usage: "Add another project",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Usage: "Project name \t"},
|
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: wd(),Usage: "Project name \t"},
|
||||||
&cli.StringFlag{Name: "path", Aliases: []string{"b"}, Value: wd(), Usage: "Project base path \t"},
|
&cli.StringFlag{Name: "path", Aliases: []string{"b"}, Value: "/", Usage: "Project base path \t"},
|
||||||
&cli.BoolFlag{Name: "build", Value: false, Usage: "Enable go build"},
|
&cli.BoolFlag{Name: "build", Value: false, Usage: "Enable go build"},
|
||||||
&cli.BoolFlag{Name: "run", Usage: "Disable go run"},
|
&cli.BoolFlag{Name: "run", Usage: "Disable go run"},
|
||||||
&cli.BoolFlag{Name: "bin", Usage: "Disable go install"},
|
&cli.BoolFlag{Name: "bin", Usage: "Disable go install"},
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config struct contains the general informations about a project
|
// Config struct contains the general informations about a project
|
||||||
|
@ -20,7 +21,14 @@ type Config struct {
|
||||||
// NameParam check the project name presence. If empty takes the working directory name
|
// NameParam check the project name presence. If empty takes the working directory name
|
||||||
func nameParam(params *cli.Context) string {
|
func nameParam(params *cli.Context) string {
|
||||||
var name string
|
var name string
|
||||||
if params.String("name") == "" {
|
if params.String("name") == "" && params.String("path") == "/"{
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(Red(err))
|
||||||
|
}
|
||||||
|
wd := strings.Split(dir, "/")
|
||||||
|
return wd[len(wd)-1]
|
||||||
|
} else if params.String("path") != "/" {
|
||||||
name = params.String("path")
|
name = params.String("path")
|
||||||
} else {
|
} else {
|
||||||
name = params.String("name")
|
name = params.String("name")
|
||||||
|
|
|
@ -55,7 +55,6 @@ func (h *Config) Fast(params *cli.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
fast.Name = fast.Path
|
|
||||||
fast.Path = ""
|
fast.Path = ""
|
||||||
go fast.Watching()
|
go fast.Watching()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
Loading…
Reference in New Issue