mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
add command "bee pro toml" for create beegopro.toml
This commit is contained in:
parent
8b942b1f22
commit
8f0badc630
@ -47,6 +47,8 @@ func BeegoPro(cmd *commands.Command, args []string) int {
|
||||
switch gcmd {
|
||||
case "gen":
|
||||
beegopro.DefaultBeegoPro.Run()
|
||||
case "toml":
|
||||
beegopro.DefaultBeegoPro.InitToml()
|
||||
case "config":
|
||||
beegopro.DefaultBeegoPro.GenConfig()
|
||||
case "migration":
|
||||
|
@ -2,16 +2,18 @@ package beegopro
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/beego/bee/internal/pkg/git"
|
||||
"github.com/beego/bee/internal/pkg/system"
|
||||
beeLogger "github.com/beego/bee/logger"
|
||||
"github.com/beego/bee/utils"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/spf13/viper"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const MDateFormat = "20060102_150405"
|
||||
@ -60,6 +62,24 @@ func (c *Container) Run() {
|
||||
c.flushTimestamp()
|
||||
}
|
||||
|
||||
func (c *Container) InitToml() {
|
||||
if exist := utils.IsExist(c.BeegoProFile); exist {
|
||||
beeLogger.Log.Fatalf("file beegopro.toml already exists")
|
||||
}
|
||||
sourceFile := c.UserOption.GitLocalPath + "/beegopro.toml"
|
||||
input, err := ioutil.ReadFile(sourceFile)
|
||||
if err != nil {
|
||||
beeLogger.Log.Fatalf("read beegopro.toml file err, %s", err.Error())
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(c.BeegoProFile, input, 0644)
|
||||
if err != nil {
|
||||
beeLogger.Log.Fatalf("create beegopro.toml file err, %s", err.Error())
|
||||
return
|
||||
}
|
||||
beeLogger.Log.Success("Successfully created file beegopro.toml")
|
||||
}
|
||||
|
||||
func (c *Container) initUserOption() {
|
||||
if !utils.IsExist(c.BeegoProFile) {
|
||||
beeLogger.Log.Fatalf("beego pro config is not exist, beego json path: %s", c.BeegoProFile)
|
||||
|
Loading…
Reference in New Issue
Block a user