1
0
mirror of https://github.com/beego/bee.git synced 2025-07-14 13:11:01 +00:00

Add override param to bee generate appcode

This commit is contained in:
neontx
2018-01-21 22:15:42 +08:00
parent 4ca7777c32
commit 32fc8f4b1a
4 changed files with 16 additions and 7 deletions

View File

@ -22,3 +22,4 @@ var Level utils.DocValue
var Tables utils.DocValue
var Fields utils.DocValue
var DDL utils.DocValue
var Override utils.DocValue

View File

@ -753,8 +753,7 @@ func writeModelFiles(tables []*Table, mPath string) {
var f *os.File
var err error
if utils.IsExist(fpath) {
beeLogger.Log.Warnf("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath)
if utils.AskForConfirmation() {
if Override == "y" || utils.WarningBeforeAskForConfirmation("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath) {
f, err = os.OpenFile(fpath, os.O_RDWR|os.O_TRUNC, 0666)
if err != nil {
beeLogger.Log.Warnf("%s", err)
@ -812,8 +811,7 @@ func writeControllerFiles(tables []*Table, cPath string, pkgPath string) {
var f *os.File
var err error
if utils.IsExist(fpath) {
beeLogger.Log.Warnf("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath)
if utils.AskForConfirmation() {
if Override == "y" || utils.WarningBeforeAskForConfirmation("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath) {
f, err = os.OpenFile(fpath, os.O_RDWR|os.O_TRUNC, 0666)
if err != nil {
beeLogger.Log.Warnf("%s", err)
@ -862,8 +860,7 @@ func writeRouterFile(tables []*Table, rPath string, pkgPath string) {
var f *os.File
var err error
if utils.IsExist(fpath) {
beeLogger.Log.Warnf("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath)
if utils.AskForConfirmation() {
if Override == "y" || utils.WarningBeforeAskForConfirmation("'%s' already exists. Do you want to overwrite it? [Yes|No] ", fpath) {
f, err = os.OpenFile(fpath, os.O_RDWR|os.O_TRUNC, 0666)
if err != nil {
beeLogger.Log.Warnf("%s", err)