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 {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
fmt.Println(r.Red(err))
|
||||
return "/"
|
||||
log.Fatal(r.Red(err))
|
||||
}
|
||||
wd := strings.Split(dir, "/")
|
||||
return wd[len(wd)-1]
|
||||
|
@ -75,7 +74,7 @@ func main() {
|
|||
},
|
||||
Action: func(p *cli.Context) error {
|
||||
y := r.New(p)
|
||||
y.Projects[0].Path = wd()
|
||||
y.Projects[0].Path = "/"
|
||||
return handle(y.Fast(p))
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
|
@ -89,8 +88,8 @@ func main() {
|
|||
Aliases: []string{"a"},
|
||||
Usage: "Add another project",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Usage: "Project name \t"},
|
||||
&cli.StringFlag{Name: "path", Aliases: []string{"b"}, Value: wd(), Usage: "Project base path \t"},
|
||||
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: wd(),Usage: "Project name \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: "run", Usage: "Disable go run"},
|
||||
&cli.BoolFlag{Name: "bin", Usage: "Disable go install"},
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"log"
|
||||
)
|
||||
|
||||
// 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
|
||||
func nameParam(params *cli.Context) 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")
|
||||
} else {
|
||||
name = params.String("name")
|
||||
|
|
|
@ -55,7 +55,6 @@ func (h *Config) Fast(params *cli.Context) error {
|
|||
}
|
||||
}
|
||||
wg.Add(1)
|
||||
fast.Name = fast.Path
|
||||
fast.Path = ""
|
||||
go fast.Watching()
|
||||
wg.Wait()
|
||||
|
|
Loading…
Reference in New Issue