check the gopath before start
This commit is contained in:
parent
09873ae083
commit
9ef0d84ab6
24
main.go
24
main.go
|
@ -1,10 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
r "github.com/tockins/realize/realize"
|
r "github.com/tockins/realize/realize"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,13 +21,18 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
header := func() {
|
header := func() error {
|
||||||
app.Information()
|
app.Information()
|
||||||
|
gopath := os.Getenv("GOPATH")
|
||||||
|
if gopath == "" {
|
||||||
|
log.Fatal(r.Red("$GOPATH isn't set up properly"))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
fmt.Println(r.Red(err))
|
||||||
return "/"
|
return "/"
|
||||||
}
|
}
|
||||||
|
@ -38,7 +44,7 @@ func main() {
|
||||||
Name: app.Name,
|
Name: app.Name,
|
||||||
Version: app.Version,
|
Version: app.Version,
|
||||||
Authors: []*cli.Author{
|
Authors: []*cli.Author{
|
||||||
&cli.Author{
|
{
|
||||||
Name: app.Author,
|
Name: app.Author,
|
||||||
Email: app.Email,
|
Email: app.Email,
|
||||||
},
|
},
|
||||||
|
@ -65,9 +71,9 @@ func main() {
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Usage: "Project name \t"},
|
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Usage: "Project name \t"},
|
||||||
&cli.StringFlag{Name: "base", Aliases: []string{"b"}, Value: wd(), Usage: "Project base path \t"},
|
&cli.StringFlag{Name: "base", Aliases: []string{"b"}, Value: wd(), 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"},
|
||||||
},
|
},
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
y := r.New(p)
|
y := r.New(p)
|
||||||
|
|
Loading…
Reference in New Issue