mirror of
https://github.com/beego/bee.git
synced 2025-07-05 18:20:18 +00:00
Use package com colorlog for uniform management
This commit is contained in:
14
new.go
14
new.go
@ -5,6 +5,8 @@ import (
|
||||
"os"
|
||||
path "path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
)
|
||||
|
||||
var cmdNew = &Command{
|
||||
@ -40,15 +42,15 @@ func init() {
|
||||
func createApp(cmd *Command, args []string) {
|
||||
curpath, _ := os.Getwd()
|
||||
if len(args) != 1 {
|
||||
colorLog("[ERRO] Argument [appname] is missing\n")
|
||||
com.ColorLog("[ERRO] Argument [appname] is missing\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
colorLog("[ERRO] $GOPATH not found\n")
|
||||
colorLog("[HINT] Set $GOPATH in your environment vairables\n")
|
||||
com.ColorLog("[ERRO] $GOPATH not found\n")
|
||||
com.ColorLog("[HINT] Set $GOPATH in your environment vairables\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
haspath := false
|
||||
@ -66,8 +68,8 @@ func createApp(cmd *Command, args []string) {
|
||||
}
|
||||
|
||||
if !haspath {
|
||||
colorLog("[ERRO] Unable to create an application outside of $GOPATH(%s)\n", gopath)
|
||||
colorLog("[HINT] Change your work directory by `cd ($GOPATH%ssrc)`\n", string(path.Separator))
|
||||
com.ColorLog("[ERRO] Unable to create an application outside of $GOPATH(%s)\n", gopath)
|
||||
com.ColorLog("[HINT] Change your work directory by `cd ($GOPATH%ssrc)`\n", string(path.Separator))
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@ -110,7 +112,7 @@ func createApp(cmd *Command, args []string) {
|
||||
fmt.Println(path.Join(apppath, "main.go"))
|
||||
writetofile(path.Join(apppath, "main.go"), strings.Replace(maingo, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), string(path.Separator)), -1))
|
||||
|
||||
colorLog("[SUCC] New application successfully created!\n")
|
||||
com.ColorLog("[SUCC] New application successfully created!\n")
|
||||
}
|
||||
|
||||
var appconf = `appname = {{.Appname}}
|
||||
|
Reference in New Issue
Block a user