diff --git a/main.go b/main.go index 6d69890..d9aa312 100644 --- a/main.go +++ b/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"}, diff --git a/realize/config.go b/realize/config.go index 3d31604..4f1dc3d 100644 --- a/realize/config.go +++ b/realize/config.go @@ -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") diff --git a/realize/watcher.go b/realize/watcher.go index 87f3a63..962ca3c 100644 --- a/realize/watcher.go +++ b/realize/watcher.go @@ -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()